我有一个数组“猫”,“狗”,“鹦鹉”
并想索引中删除该项目。
目前,我有
function removeit(myindex) {
animals[myindex] = animals.pop()
}
我有一个数组“猫”,“狗”,“鹦鹉”
并想索引中删除该项目。
目前,我有
function removeit(myindex) {
animals[myindex] = animals.pop()
}
你想拼接
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Array.html#splice%28%29
方法Array.splice(起点,删除计数);
var newArray:Array = myArray.splice(2, 1); //this removes whatever is at index 2 and returns it in a new array.
更改功能
function removeit(myindex) {
animals.splice(myindex, 1);
}
当使用Flash Player 19+或19+ AIR,您可以使用
myArray.removeAt(myIndex); // removes the element at the specified index, modifying the array without making a copy
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Array.html#removeAt()