我有一個數組'貓','狗','budgie'as3 array按索引刪除
並希望通過索引刪除項目。
目前,我有
function removeit(myindex) {
animals[myindex] = animals.pop()
}
我有一個數組'貓','狗','budgie'as3 array按索引刪除
並希望通過索引刪除項目。
目前,我有
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()
你的意思是'動物[myindex ] = null'?你想要什麼最終結果? – 2012-04-10 13:33:38
如果我通過'貓我想要它','狗',budgie'。我可以刪除我傳遞給函數 – LeBlaireau 2012-04-10 13:36:26
的項目,如果您將答案標記爲正確,那麼以後人們將更傾向於幫助您 – francis 2012-04-11 23:07:58