Array.splice()
Top  Previous  Next


SWiSH Player Support
SWF5 or later - Supported Internally

Syntax
arrayName.splice(start,deletecount,{value...});

Arguments
start: The array's index value where the splice begins.
deletecount: The number of elements (including the element specified by the start argument) to be deleted. If this value is set to zero, then no elements are deleted.
value(s): Optional elements to be added to the array at the index value specified by the start argument.

Returns
Nothing.

Description
Method; inserts or deletes elements from an array.

Samples
onLoad() {
    nickNames = new Array("Snookie","Piggy","Shorty","Slim");
    nickNames.splice(3,0,"Tiny");
    trace(nickNames.join());
}

// displays "Snookie,Piggy,Shorty,Tiny,Slim" in the debug window

onLoad() {
    nickNames = new Array("Snookie","Piggy","Shorty","Slim");
    nickNames.splice(3,1);
    trace(nickNames.join());
}
// displays "Snookie,Piggy,Shorty" in the debug window