Reverse (Array.reverse Method); Shift (Array.shift Method); Slice (Array.slice Method) - MACROMEDIA FLASHLITE2 ACTIONSCRIPT-LANGUAGE Reference

Actionscript language reference
Table of Contents

Advertisement

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
- The first element in an array.
Object
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
258
ActionScript classes

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASHLITE2 ACTIONSCRIPT-LANGUAGE and is the answer not in the manual?

This manual is also suitable for:

Flash lite 2

Table of Contents