除去从阵列中的多个对象
-
13-09-2019 - |
题
我放置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的方式?
解决方案
你的意思是数组中删除您还想删除那些从舞台?的影片剪辑
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
不隶属于 StackOverflow