25 July 2010
Scope refers to the section of ActionScript in which the variables and other elements are active. When you place static variables and static functions in classes, you may find that the code that worked in the Timeline in Adobe Flash Professional no longer works when its scope has changed.
You can update the code to work again by using the following syntax:
When you move ActionScript code into classes, you might discover that you have to change how you use the
this keyword. For example, if you have a class method that uses a callback function (such as the
onLoad() method of the LoadVars class), it can be difficult to know whether the
this keyword refers to the class or the LoadVars object. In this situation, it might be necessary to create a pointer (path) that leads to the class using dot syntax.
For example, if you are trying to reference the private member variable within an onLoad handler, the
this keyword actually refers to the function's instance and not the class, as you might expect. For this reason, you must create a pointer to the local class file so that you can directly reference the class from the onLoad handler. After adding the path, you can use this class with a Flash document.
To learn more about scope when working with static variables and functions, see the following resources: