User Guide

258 ActionScript classes
reverse (Array.reverse method)
public reverse() : Void
Reverses the array in place.
Availability: ActionScript 1.0; Flash Lite 2.0
Example
The following example uses this method to reverse the array
numbers_array:
var numbers_array:Array = new Array(1, 2, 3, 4, 5, 6);
trace(numbers_array); // Displays 1,2,3,4,5,6.
numbers_array.reverse();
trace(numbers_array); // Displays 6,5,4,3,2,1.
shift (Array.shift method)
public shift() : Object
Removes the first element from an array and returns that element.
Availability: ActionScript 1.0; Flash Lite 2.0
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)
slice (Array.slice method)
public slice([startIndex:Number], [endIndex:Number]) : Array
Returns a new array that consists of a range of elements from the original array, without
modifying the original array. The returned array includes the
startIndex element and all
elements up to, but not including, the
endIndex element.