2009-11-03 122 views
0

我把MC放在一個數組中,並希望稍後從索引中刪除它,直到結束爲止。從陣列中刪除多個對象

//Removeing MC from stage, from an index till the end 
LISTmc.removeChild(listArray[clickedIndex+1]); 

//Removing MC starting from an index till the end 
listArray.splice(clickedIndex+1); 

是從階段中刪除MC從數組中刪除它的方式嗎?

回答

1

你的意思是說,對於數組中的動畫片段你刪除你也想從舞臺上刪除那些?

for (var i:int = clickedIndex+1; i < listArray.length;i++) 
{ 
    //if this is on timeline leave as is otherwise you need to reference stage 
    removeChild(listArray[i]); 

    //if the movieclips are in various movieclips then you can do: 
    // var parent:DisplayObject = (listArray[i]).parent; 
    // parent.removeChild(listArray[i]); 

} 

listArray = listArray.slice(0,clickedIndex);//returns a new array from start index to end index