Monday, December 17, 2012

Indexed arrays

Indexed arrays store a series of one or more values organized such that each value can be accessed using an unsigned integer value. The first index is always the number 0, and the index increments by one for each subsequent element added to the array. You can create an indexed array by calling the Array constructor, or by initializing the array with an array literal.
// use Array constructor
var myArray:Array = new Array();
myArray.push("one");
myArray.push("two");
myArray.push("three");
trace (myArray); // Output: one,two,three
// use Array literal
var myArray:Array = ["one", "two", "three"];
trace (myArray); // Output: one,two,three
Programming Actionscript 3. Powered by Blogger.