The top level is the unnamed package that every ActionScript 3.0 file can use without
an import. It holds the core language: 4 constants, 22 functions and 30
classes, all available from Flash Player 9 and AIR 1.0 unless a note says otherwise.
Most of it follows ECMAScript edition 3; the rest is ActionScript’s own.
Global constants
| Constant | Type | Value |
|---|---|---|
Infinity | Number | Positive infinity, the same as Number.POSITIVE_INFINITY. |
-Infinity | Number | Negative infinity, the same as Number.NEGATIVE_INFINITY. |
NaN | Number | Not a number. It equals nothing, itself included; test with isNaN(). |
undefined | * | The value of untyped variables and dynamic properties that were never set. |
Global functions
| Function | Does |
|---|---|
Array(...args):Array | Makes an array, like new Array; a single number gives an empty array of that length. |
Boolean(expression):Boolean | Converts to Boolean. |
decodeURI(uri:String):String | Decodes a URI encoded by encodeURI. |
decodeURIComponent(uri:String):String | Decodes a part encoded by encodeURIComponent. |
encodeURI(uri:String):String | Encodes a whole URI as UTF-8 escapes, keeping its separators. |
encodeURIComponent(uri:String):String | Encodes one part of a URI, separators included. |
escape(str:String):String | URL-encodes a string, the older way. |
int(value):int | Converts to a 32-bit signed integer, cutting off any fraction. |
isFinite(num:Number):Boolean | False for Infinity, -Infinity and NaN. |
isNaN(num:Number):Boolean | Whether the value is NaN. |
isXMLName(str:String):Boolean | Whether the string is a valid XML element or attribute name. |
Number(expression):Number | Converts to Number. |
Object(value):Object | Gives the value back, as an object. |
parseFloat(str:String):Number | Reads a decimal number from the start of a string, or NaN. |
parseInt(str:String, radix:uint = 0):Number | Reads an integer in base 2 to 36 from the start of a string, or NaN; radix 0 means 10, or 16 after 0x. |
String(expression):String | Converts to String. |
trace(...arguments):void | Writes the values, separated by spaces, to the debugger’s output or the debug player’s log. Release players ignore it. |
uint(value):uint | Converts to a 32-bit unsigned integer. |
unescape(str:String):String | Decodes a URL-encoded string. |
Vector.<T>(source):Vector.<T> | Makes a vector from an array or another vector (Flash Player 10, AIR 1.5). |
XML(expression):XML | Converts or parses to XML; throws for null and undefined. |
XMLList(expression):XMLList | Converts or parses to XMLList; throws for null and undefined. |
There is no eval: code cannot be compiled at run time.
Top-level classes
| Class | Is |
|---|---|
Object | The root of every class. |
Boolean, int, uint, Number, String | The primitive types. See Data types. |
Array | A growable list of any values. |
Vector | A list whose elements share one type (Flash Player 10, AIR 1.5). |
Function | A function or method closure, with call, apply and length. |
arguments | The arguments of the running function. |
Class | The type of every class object. |
Date | A date and time, with local and UTC getters and setters and Date.parse, Date.UTC. |
Math | Constants (E, LN10, LN2, LOG10E, LOG2E, PI, SQRT1_2, SQRT2) and static functions (abs, acos, asin, atan, atan2, ceil, cos, exp, floor, log, max, min, pow, random, round, sin, sqrt, tan). |
RegExp | A regular expression. See Regular expressions. |
XML, XMLList | E4X XML. See XML and E4X. |
Namespace, QName | A namespace, and a name qualified by one, for XML and for the language. |
JSON | JSON.parse(text, reviver) and JSON.stringify(value, replacer, space) (Flash Player 11, AIR 3). |
Error | The base error class. |
ArgumentError, DefinitionError, EvalError, RangeError, ReferenceError, SecurityError, SyntaxError, TypeError, URIError, VerifyError | The built-in errors. See Errors and exceptions. |
Package-level functions
Some functions that look global live in packages and must be imported, as
import flash.utils.getTimer;.
| Function | Package | Does |
|---|---|---|
getTimer():int | flash.utils | Milliseconds since the runtime started. |
setTimeout, clearTimeout, setInterval, clearInterval | flash.utils | Call a function once after a delay, or repeatedly; Timer is the event-based way. |
getDefinitionByName(name:String):Object | flash.utils | The class or function with that full name, such as "flash.display.Sprite". |
getQualifiedClassName(value):String, getQualifiedSuperclassName(value):String | flash.utils | The full class name of a value or of its superclass, as "flash.display::Sprite". |
describeType(value):XML | flash.utils | The type of a value as XML: its class, superclasses, interfaces, properties, methods and kept metadata. |
escapeMultiByte, unescapeMultiByte | flash.utils | URL-encoding using the system code page or UTF-8. |
navigateToURL(request, window), sendToURL(request) | flash.net | Open a web page; send a request and ignore the answer. |
registerClassAlias(alias, class), getClassByAlias(alias) | flash.net | Name a class for AMF serialisation, so typed objects survive ByteArray.writeObject, shared objects and remoting. |
fscommand(command, args) | flash.system | Sends a command to the standalone player or the host page. |
The classes of the flash packages are listed on
Flash and AIR packages.