03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Availability: <strong>ActionScript</strong> 1.0; Flash Player 5<br />

Returns<br />

Object - The first element in an array.<br />

Example<br />

The following code creates the array myPets_array <strong>and</strong> then removes the first element from<br />

the array <strong>and</strong> assigns it to the variable shifted:<br />

var myPets_array:Array = new Array("cat", "dog", "bird", "fish");<br />

var shifted:Object = myPets_array.shift();<br />

trace(shifted); // Displays "cat".<br />

trace(myPets_array); // Displays dog,bird,fish.<br />

See also<br />

pop (Array.pop method), push (Array.push method), unshift (Array.unshift<br />

method)<br />

slice (Array.slice method)<br />

public slice([startIndex:Number], [endIndex:Number]) : Array<br />

Returns a new array that consists of a range of elements from the original array, without<br />

modifying the original array. The returned array includes the startIndex element <strong>and</strong> all<br />

elements up to, but not including, the endIndex element.<br />

If you don't pass any parameters, a duplicate of the original array is created.<br />

Availability: <strong>ActionScript</strong> 1.0; Flash Player 5<br />

Parameters<br />

startIndex:Number [optional] - A number specifying the index of the starting point for the<br />

slice. If start is a negative number, the starting point begins at the end of the array, where -1<br />

is the last element.<br />

endIndex:Number [optional] - A number specifying the index of the ending point for the<br />

slice. If you omit this parameter, the slice includes all elements from the starting point to the<br />

end of the array. If end is a negative number, the ending point is specified from the end of the<br />

array, where -1 is the last element.<br />

Returns<br />

Array - An array that consists of a range of elements from the original array.<br />

Array 261

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!