O'Reilly logo

Essential ActionScript 3.0 by Colin Moock

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Internal Details

Internally, ActionScript uses a list of objects to keep track of the definitions in the scope chain. The objects used to track the definitions of each scope are as follows:

Global scope

The global object (an object created automatically by ActionScript to hold global definitions)

Class scope

The class's Class object (and the Class objects of the class's ancestors)

Static method scope

The class's Class object (and the Class objects of the class's ancestors)

Instance method scope

The current object (this) and an activation object (an activation object is an object created and stored internally by ActionScript and maintains the local variables and parameters of function or method)

Function scope

An activation object

When ActionScript encounters an identifier expression in an program, it searches for that identifier among the objects in the scope chain. For example, consider the following code:

package {
  public class SomeClass {
    public function instanceMeth ():void {
      function nestedFunc ():void {
        trace(a);
      }
    }
  }
}
var a:int = 15;

In the preceding code, when ActionScript encounters the identifier a, it begins a search for the value of that identifier with nestedFunc( )'s activation object. But nestedFunc( ) does not define any local variables or parameters named a, so ActionScript next searches for a on the current object (i.e., the object through which instanceMeth( ) was invoked). But SomeClass does not define or inherit an instance method or instance variable named a, so ActionScript ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required