我有一个数组'cat','dog','budgie'
并希望按索引删除该项目。
此刻我有
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);
}