shift (Array.shift method)

public shift() : Object

Removes the first element from an array and returns that element.

Availability: ActionScript 1.0; Flash Player 5

Returns

Object - The first element in an array.

Example

The following code creates the array myPets_array and then removes the first element from the array and assigns it to the variable shifted:

var myPets_array:Array = new Array("cat", "dog", "bird", "fish");
var shifted:Object = myPets_array.shift();
trace(shifted); // Displays "cat".
trace(myPets_array); // Displays dog,bird,fish.

See also

pop (Array.pop method), push (Array.push method), unshift (Array.unshift method)


Flash CS3


 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/9.0/main/00001364.html