从数组中删除多个对象

时间:2009-11-03 09:33:30

标签: actionscript-3 arrays removechild

我将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 个答案:

答案 0 :(得分:1)

您的意思是对于您删除的数组中的MovieClip,您还想从舞台中删除它们吗?

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