MACROMEDIA FLEX-FLEX ACTIONSCRIPT LANGUAGE Reference page 248

Actionscript language reference
Table of Contents

Advertisement

Description
Method; 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
to, but not including, the
If you don't pass any parameters, a duplicate of
Example
The following example creates an array of five pets and uses
comprising only four-legged pets:
var myPets_array:Array = new Array("cat", "dog", "fish", "canary", "parrot");
var myFourLeggedPets_array:Array = new Array();
var myFourLeggedPets_array = myPets_array.slice(0, 2);
trace(myFourLeggedPets_array);
trace(myPets_array);
The following example creates an array of five pets, and then uses
parameter to copy the last two elements from the array:
var myPets_array:Array = new Array("cat", "dog", "fish", "canary", "parrot");
var myFlyingPets_array:Array = myPets_array.slice(-2);
trace(myFlyingPets_array); // traces canary,parrot
The following example creates an array of five pets and uses
parameter to copy the middle element from the array:
var myPets_array:Array = new Array("cat", "dog", "fish", "canary", "parrot");
var myAquaticPets_array:Array = myPets_array.slice(2,-2);
trace(myAquaticPets_array); // returns fish
Array.sort()
Availability
Flash Player 5; additional capabilities added in Flash Player 7.
Usage
my_array.sort() : Array
my_array.sort(compareFunction:Function) : Array
my_array.sort(option:Number | option |... ) : Array
my_array.sort(compareFunction:Function, option:Number | option |... ) : Array
Parameters
compareFunction
an array. Given the elements A and B, the result of
following three values:
-1, if A should appear before B in the sorted sequence
0, if A equals B
1, if A should appear after B in the sorted sequence
248
Chapter 6: ActionScript Core Classes
element.
end
// returns cat,dog
// returns cat,dog,fish,canary,parrot
A comparison function used to determine the sorting order of elements in
element and all elements up
start
is created.
my_array
slice()
slice()
slice()
compareFunction
to populate a new array
with a negative
start
with a negative
end
can have one of the

Advertisement

Table of Contents
loading
Need help?

Need help?

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

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flex

Table of Contents