MACROMEDIA FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE Reference page 259

Flash lite 2.x actionscript language reference
Hide thumbs Also See for FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE:
Table of Contents

Advertisement

If you don't pass any parameters, a duplicate of the original array is created.
Availability: ActionScript 1.0; Flash Lite 2.0
Parameters
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
end
array, where -1 is the last element.
Returns
- An array that consists of a range of elements from the original array.
Array
Example
The following example creates an array of five pets and uses
that contains 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); // Returns cat,dog.
trace(myPets_array); // Returns cat,dog,fish,canary,parrot.
The following example creates an array of five pets, and then uses
parameter to copy the last two elements from the array:
start
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.
[optional] - A number specifying the index of the starting point for the
is a negative number, the ending point is specified from the end of the
to populate a new array
slice()
with a negative
slice()
with a negative
slice()
end
Array
259

Advertisement

Table of Contents
loading

Table of Contents