Array()
Availability
Flash Player 6.
Usage
Array() : Array
Array(numElements:Number) : Array
Array( [element0:Object [, element1 , element2,...elementN ] ]) : Array
Parameters
One or more elements to place in the array.
element
Returns
An array.
Description
Conversion function; creates a new, empty array or converts specified elements to an array. Using
this function is similar to creating an array with the Array constructor (see
Array class" on page
Example
Usage 1: The following example adds items to an array by using the array's index and then by
using the Array class's
var myArray:Array = Array();
myArray.push(12);
trace(myArray); //traces 12
myArray[4] = 7;
trace(myArray); //traces 12,undefined,undefined,undefined,7
Usage 2: The following example creates an array of length 4 but with no elements defined:
var myArray:Array = Array(4);
trace(myArray.length);
trace(myArray); // traces undefined,undefined,undefined,undefined
Usage 3: The following example creates an array with three defined elements:
var myArray:Array = Array(["firstElement", "secondElement", "thirdElement"]);
trace (myArray); // traces firstElement,secondElement,thirdElement
Note: Unlike the Array class constructor, the Array() function does not use the keyword new.
See also
Array class
ActionScript Core Language Elements
241).
method:
push
// traces 4
CHAPTER 5
"Constructor for the
Array()
131
Need help?
Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?