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
The members are the ones each class declares in Adobe’s reference; every class also
has Object’s. “(static)” marks a member of the class itself.
| Class | Is | Members |
|---|---|---|
Object | The root of every class. | constructor:Object, prototype:Object (static), Object(), hasOwnProperty(name:String):Boolean, isPrototypeOf(theClass:Object):Boolean, propertyIsEnumerable(name:String):Boolean, setPropertyIsEnumerable(name:String, isEnum:Boolean = true):void, toLocaleString():String, toString():String, valueOf():Object |
Boolean | A primitive type. See Data types. | Boolean(expression:Object = false), toString():String, valueOf():Boolean |
Number | A 64-bit floating-point number. | MAX_VALUE, MIN_VALUE, NaN, NEGATIVE_INFINITY, POSITIVE_INFINITY (static, Number), Number(num:Object), toExponential(fractionDigits:uint):String, toFixed(fractionDigits:uint):String, toPrecision(precision:uint):String, toString(radix:Number = 10):String, valueOf():Number |
int | A 32-bit signed integer. | MAX_VALUE:int, MIN_VALUE:int (static), int(num:Object), toExponential(fractionDigits:uint):String, toFixed(fractionDigits:uint):String, toPrecision(precision:uint):String, toString(radix:uint):String, valueOf():int |
uint | A 32-bit unsigned integer. | MAX_VALUE:uint, MIN_VALUE:uint (static), uint(num:Object), toExponential(fractionDigits:uint):String, toFixed(fractionDigits:uint):String, toPrecision(precision:uint):String, toString(radix:uint):String, valueOf():uint |
String | Text, as UTF-16. | length:int (read-only), String(val:String), charAt(index:Number = 0):String, charCodeAt(index:Number = 0):Number, concat(...args):String, fromCharCode(...charCodes):String (static), indexOf(val:String, startIndex:Number = 0):int, lastIndexOf(val:String, startIndex:Number = 0x7FFFFFFF):int, localeCompare(other:String, ...values):int, match(pattern:*):Array, replace(pattern:*, repl:Object):String, search(pattern:*):int, slice(startIndex:Number = 0, endIndex:Number = 0x7fffffff):String, split(delimiter:*, limit:Number = 0x7fffffff):Array, substr(startIndex:Number = 0, len:Number = 0x7fffffff):String, substring(startIndex:Number = 0, endIndex:Number = 0x7fffffff):String, toLocaleLowerCase():String, toLocaleUpperCase():String, toLowerCase():String, toUpperCase():String, valueOf():String |
Array | A growable list of any values. | length:uint, CASEINSENSITIVE, DESCENDING, NUMERIC, RETURNINDEXEDARRAY, UNIQUESORT (static, uint), Array(...values), concat(...args):Array, every(callback:Function, thisObject:* = null):Boolean, filter(callback:Function, thisObject:* = null):Array, forEach(callback:Function, thisObject:* = null):void, indexOf(searchElement:*, fromIndex:int = 0):int, insertAt(index:int, element:*):void (Flash Player 19, AIR 19), join(sep:*):String, lastIndexOf(searchElement:*, fromIndex:int = 0x7fffffff):int, map(callback:Function, thisObject:* = null):Array, pop():*, push(...args):uint, removeAt(index:int):* (Flash Player 19, AIR 19), reverse():Array, shift():*, slice(startIndex:int = 0, endIndex:int = 16777215):Array, some(callback:Function, thisObject:* = null):Boolean, sort(...args):Array, sortOn(fieldName:Object, options:Object = null):Array, splice(startIndex:int, deleteCount:uint, ...values):Array, toLocaleString():String, toString():String, unshift(...args):uint |
Vector.<T> | A list whose elements share one type T (Flash Player 10, AIR 1.5). | fixed:Boolean, length:uint, Vector(length:uint = 0, fixed:Boolean = false), concat(...args):Vector.<T>, every(callback:Function, thisObject:Object = null):Boolean, filter(callback:Function, thisObject:Object = null):Vector.<T>, forEach(callback:Function, thisObject:Object = null):void, indexOf(searchElement:T, fromIndex:int = 0):int, insertAt(index:int, element:T):void (Flash Player 19, AIR 19), join(sep:String = ","):String, lastIndexOf(searchElement:T, fromIndex:int = 0x7fffffff):int, map(callback:Function, thisObject:Object = null):Vector.<T>, pop():T, push(...args):uint, removeAt(index:int):T (Flash Player 19, AIR 19), reverse():Vector.<T>, shift():T, slice(startIndex:int = 0, endIndex:int = 16777215):Vector.<T>, some(callback:Function, thisObject:Object = null):Boolean, sort(sortBehavior:*):Vector.<T>, splice(startIndex:int, deleteCount:uint = 4294967295, ...items):Vector.<T>, toLocaleString():String, toString():String, unshift(...args):uint |
Function | A function or method closure. | length (the number of declared parameters), apply(thisArg:*, argArray:*):*, call(thisArg:*, ...args):* |
arguments | The arguments of the running function. | callee:Function, length:Number |
Class | The type of every class object. | None of its own |
Date | A date and time, in local time or UTC. | Properties, all Number: date, dateUTC, day (read-only), dayUTC (read-only), fullYear, fullYearUTC, hours, hoursUTC, milliseconds, millisecondsUTC, minutes, minutesUTC, month, monthUTC, seconds, secondsUTC, time, timezoneOffset (read-only).Date(yearOrTimevalue:Object, month:Number, date:Number = 1, hour:Number = 0, minute:Number = 0, second:Number = 0, millisecond:Number = 0); getters returning Number: getDate(), getDay(), getFullYear(), getHours(), getMilliseconds(), getMinutes(), getMonth(), getSeconds(), getTime(), getTimezoneOffset(), getUTCDate(), getUTCDay(), getUTCFullYear(), getUTCHours(), getUTCMilliseconds(), getUTCMinutes(), getUTCMonth(), getUTCSeconds(); setters returning the new time as Number: setDate(day), setFullYear(year, month, day), setHours(hour, minute, second, millisecond), setMilliseconds(millisecond), setMinutes(minute, second, millisecond), setMonth(month, day), setSeconds(second, millisecond), setTime(millisecond), setUTCDate(day), setUTCFullYear(year, month, day), setUTCHours(hour, minute, second, millisecond), setUTCMilliseconds(millisecond), setUTCMinutes(minute, second, millisecond), setUTCMonth(month, day), setUTCSeconds(second, millisecond); toDateString():String, toJSON(k:String):*, toLocaleDateString():String, toLocaleString():String, toLocaleTimeString():String, toString():String, toTimeString():String, toUTCString():String, valueOf():Number; static parse(date:String):Number and UTC(year:Number, month:Number, date:Number = 1, hour:Number = 0, minute:Number = 0, second:Number = 0, millisecond:Number = 0):Number |
Math | Mathematics; every member is static. | Constants E, LN10, LN2, LOG10E, LOG2E, PI, SQRT1_2, SQRT2; functions abs, acos, asin, atan, atan2, ceil, cos, exp, floor, log, max, min, pow, random, round, sin, sqrt, tan, all on Number |
RegExp | A regular expression. See Regular expressions. | dotall:Boolean, extended:Boolean, global:Boolean, ignoreCase:Boolean, multiline:Boolean, source:String (all read-only), lastIndex:Number, RegExp(re:String, flags:String), exec(str:String):Object, test(str:String):Boolean |
XML | One E4X node. See XML and E4X. | Static: ignoreComments:Boolean, ignoreProcessingInstructions:Boolean, ignoreWhitespace:Boolean, prettyIndent:int, prettyPrinting:Boolean, defaultSettings():Object, setSettings(...rest):void, settings():Object.XML(value:Object), addNamespace(ns:Object):XML, appendChild(child:Object):XML, attribute(attributeName:*):XMLList, attributes():XMLList, child(propertyName:Object):XMLList, childIndex():int, children():XMLList, comments():XMLList, contains(value:XML):Boolean, copy():XML, descendants(name:Object = *):XMLList, elements(name:Object = *):XMLList, hasComplexContent():Boolean, hasOwnProperty(p:String):Boolean, hasSimpleContent():Boolean, inScopeNamespaces():Array, insertChildAfter(child1:Object, child2:Object):*, insertChildBefore(child1:Object, child2:Object):*, length():int, localName():Object, name():Object, namespace(prefix:String = null):*, namespaceDeclarations():Array, nodeKind():String, normalize():XML, parent():*, prependChild(value:Object):XML, processingInstructions(name:String = "*"):XMLList, propertyIsEnumerable(p:String):Boolean, removeNamespace(ns:Namespace):XML, replace(propertyName:Object, value:XML):XML, setChildren(value:Object):XML, setLocalName(name:String):void, setName(name:String):void, setNamespace(ns:Namespace):void, text():XMLList, toJSON(k:String):*, toString():String, toXMLString():String, valueOf():XML |
XMLList | A list of E4X nodes. | XMLList(value:Object), attribute(attributeName:*):XMLList, attributes():XMLList, child(propertyName:Object):XMLList, children():XMLList, comments():XMLList, contains(value:XML):Boolean, copy():XMLList, descendants(name:Object = *):XMLList, elements(name:Object = *):XMLList, hasComplexContent():Boolean, hasOwnProperty(p:String):Boolean, hasSimpleContent():Boolean, length():int, normalize():XMLList, parent():Object, processingInstructions(name:String = "*"):XMLList, propertyIsEnumerable(p:String):Boolean, text():XMLList, toString():String, toXMLString():String, valueOf():XMLList |
Namespace | A namespace, for XML and for the language. | prefix:String, uri:String, Namespace(uriValue:*), Namespace(prefixValue:*, uriValue:*), toString():String, valueOf():String |
QName | A name qualified by a namespace. | localName:String, uri:String, QName(qname:QName), QName(uri:Namespace, localName:QName), toString():String, valueOf():QName |
JSON | JSON text (Flash Player 11, AIR 3). | parse(text:String, reviver:Function = null):Object, stringify(value:Object, replacer:* = null, space:* = null):String (both static) |
Error | The base error class. | errorID:int (read-only), message:String, name:String, Error(message:String = "", id:int = 0), getStackTrace():String, toString():String |
ArgumentError, DefinitionError, EvalError, RangeError, ReferenceError, SecurityError, SyntaxError, TypeError, URIError, VerifyError | The built-in errors. See Errors and exceptions. | Each has only a constructor, (message:String = ""), and Error’s members |
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.