That's an over simplification of the scope chain properties of AS3,
and "global" isn't the right word there (though I know what you meant).
To clarify the scope chain issue, keep in mind that you can nest
function scopes to create a hierarchy of scopes with a closure (usually
this is difficult for new devs in ECMAScript languages like AS3 and
Javascript to grasp). So "global" really just refers to the top of the
scope chain.
Additionally, there are also as file level scopes. For example, in a
file named getURL.as:
package {
function getURL() {
trace(topScopeVar);
}
}
var topScopeVar:String = "Hello world!";
That "topScopeVar" is only accessible from within that as file, because
it is at the top of that file's individual scope chain. A function or
class in a different as file would not have access to that variable, and
this class has no access to other seemingly "global" scopes either, like
the timeline, or other as files.
functions and classes defined in root packages, and available in the
class path, those are global, and you can define a property on those
(static var on a class for example) - that's about as close as you get
to a global in AS3.
Kevin N.
On 8/4/10 9:21 AM, Juan Pablo Califano wrote:
In actionscript you have only local and "global" scope. Meaning a variable
can be declared as local to the function or in the class that contains it.
Other languages allow for creating further scopes.
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders