About

<#TEMPLATE_INCLUDE_NINEPAGE_ABOUTME#>
  • Aug

    16

    A function's location in a program governs its ability to access the program's definitions (i.e., classes, variables, methods, namespaces, interfaces, and other functions).

    Note, however, that within a function closure, the keyword this always refers to the global object, no matter where the function is defined. To access the current object within a nested function in an instance method, assign this to a variable, as shown in the following code:

    public function m () {
        var currentObject = this;
        function f () {
            // Access to currentObject is granted here
            trace(currentObject); // Displays the object through which m() was invoked
        }
    }

     

    A function's location in a program governs its ability to access the program's definitions (i.e., classes, variables, methods, namespaces, interfaces, and other functions).

    Note, however, that within a function closure, the keyword this always refers to the global object, no matter where the function is defined. To access the current object within a nested function in an instance method, assign this to a variable, as shown in the following code:

    public function m () {
        var currentObject = this;
        function f () {
            // Access to currentObject is granted here
            trace(currentObject); // Displays the object through which m() was invoked
        }
    }

     

    Aug

    16

    Adobe's compilers place two requirements on ActionScript source files (.as files) that affect package-level functions:

    • Every ActionScript source file (.as file) must have exactly one externally visible definition. An "externally visible definition" is a class, variable, function, interface, or namespace that is defined as either internal or public within a package statement.

    • An ActionScript source file's name must match the name of its sole externally visible definition.

    Hence, while in theory, ActionScript does not place any limitations on packagelevel functions, in practice, Adobe's compilers require each package-level function to be defined as either internal or public in a separate .as file with a matching file name.