User Guide

110 Chapter 2: ActionScript Language Reference
Array.push()
Availability
Flash Player 5.
Usage
my_array.push(value,...) : Number
Parameters
value
One or more values to append to the array.
Returns
An integer representing the length of the new array.
Description
Method; adds one or more elements to the end of an array and returns the arrays new length.
Example
The following example creates the array myPets_array with two elements, cat and dog. The
second line adds two elements to the array. Because the
push() method returns the new length of
the array, the
trace() statement in the last line sends the new length of myPets_array (4) to the
Output panel.
var myPets_array:Array = new Array("cat", "dog");
var pushed:Number = myPets_array.push("bird", "fish");
trace(pushed); // displays 4
See Also
Array.pop(), Array.shift(), Array.unshift()