User Guide

322 Chapter 2: ActionScript Language Reference
_global object
Availability
Flash Player 6.
Usage
_global.identifier
Parameters
None.
Returns
A reference to the global object that holds the core ActionScript classes, such as String, Object,
Math, and Array.
Description
Identifier; creates global variables, objects, or classes. For example, you could create a library that
is exposed as a global ActionScript object, similar to the Math or Date object. Unlike Timeline-
declared or locally declared variables and functions, global variables and functions are visible to
every Timeline and scope in the SWF file, provided they are not obscured by identifiers with the
same names in inner scopes.
Example
The following example creates a top-level function, factorial(), that is available to every
Timeline and scope in a SWF file:
_global.factorial = function(n:Number) {
if (n<=1) {
return 1;
} else {
return n*factorial(n-1);
}
};
// Note: factorial 4 == 4*3*2*1 == 24
trace(factorial(4)); // output: 24
See also
var, set variable
CHAPTER 2
ActionScript Language Reference