Monday, September 17, 2007

Arrays

Arrays are the same:

var verbs:Array = ["jumped", "ran", "flew"];

//2D array:
var multiD:Array = [
["row 0 col 0","row 0 col 1"],
["row 1 col 0","row 1 col 1"],
["row 2 col 0","row 2 col 1"],
["row 3 col 0","row 3 col 1"]
];

Here is a list of Properties:
array.pop() = This method removes the last item from an array
array.push() = The push method adds a series of values to the end of an existing array
array.shift() = removes a value from the beginning of array
array.unshift() = adds a value or series of values to the beginning of your array
array.concat() = merges two arrays together ... arrayOne.concat(arrayTwo);
array.slice() = can create array with certain elements of existing array
array.sort() = will sort an array (alphabetically by default)
array.reverse() = Reverses the direction of an array.
slice() = Extracts a section of an array and returns it as a new array.
array.toString = Returns a string value representing the elements in the Array object.

var myArray:Array = new Array(); //creates a new blank array

some links to help:
http://www.kirupa.com/developer/actionscript/array2.htm
Adobe Array Help

No comments: