Array.splice()
Availability
Flash Player 5.
Usage
my_array.splice(start:Number, deleteCount:Number [, value0:Object,
value1...valueN]) : Array
Parameters
An integer that specifies the index of the element in the array where the insertion or
start
deletion begins.
deleteCount
includes the element specified in the
the method deletes all the values from the
value is 0, no elements are deleted.
An optional parameter that specifies the values to insert into the array at the insertion
value
point specified in the
Returns
The elements that were removed from the array.
Description
Method; adds and removes elements from an array. This method modifies the array without
making a copy.
Example
The following example creates an array and splices it using element index 1 for the
parameter. This removes all elements from the array starting with the second element, leaving
only the element at index 0 in the original array:
var myPets_array:Array = new Array("cat", "dog", "bird", "fish");
trace( myPets_array.splice(1) ); // dog,bird,fish
trace( myPets_array ); // cat
The following example creates an array and splices it using element index 1 for the
parameter and the number 2 for the
the array, starting with the second element, leaving the first and last elements in the original array:
var myFlowers_array:Array = new Array("roses", "tulips", "lilies", "orchids");
trace( myFlowers_array.splice(1,2 ) ); // tulips,lilies
trace( myFlowers_array ); // roses,orchids
An integer that specifies the number of elements to be deleted. This number
start
parameter.
start
deleteCount
parameter. If no value is specified for
element to the last element in the array. If the
start
parameter. This removes two elements from
,
deleteCount
start
start
Array.splice()
121
Need help?
Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?
Questions and answers