Удаление нескольких объектов из массива

Я помещаю 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 со сцены такой же, как и удаление его из массива?


person Hwang    schedule 03.11.2009    source источник


Ответы (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
person Allan    schedule 03.11.2009