Example
The following code creates the array
and then removes the first element from
myPets_array
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
element and all
startIndex
elements up to, but not including, the
element.
endIndex
If you don't pass any parameters, a duplicate of the original array is created.
Availability: ActionScript 1.0; Flash Player 5
Parameters
[optional] - A number specifying the index of the starting point for the
startIndex:Number
slice. If
is a negative number, the starting point begins at the end of the array, where -1
start
is the last element.
[optional] - A number specifying the index of the ending point for the
endIndex:Number
slice. If you omit this parameter, the slice includes all elements from the starting point to the
end of the array. If
is a negative number, the ending point is specified from the end of the
end
array, where -1 is the last element.
Returns
- An array that consists of a range of elements from the original array.
Array
Array
255
Need help?
Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?