Array
255
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.
If you don't pass any parameters, a duplicate of the original array is created.
Availability:
ActionScript 1.0; Flash Player 5
Parameters
startIndex
:Number
[optional] - A number specifying the index of the starting point for the
slice. If
start
is a negative number, the starting point begins at the end of the array, where -1
is the last element.
endIndex
:Number
[optional] - A number specifying the index of the ending point for the
slice. If you omit this parameter, the slice includes all elements from the starting point to the
end of the array. If
end
is a negative number, the ending point is specified from the end of the
array, where -1 is the last element.
Returns
Array
- An array that consists of a range of elements from the original array.
Summary of Contents for FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
Page 1: ...ActionScript 2 0 Language Reference ...
Page 1352: ...1352 ActionScript classes ...