2009-11-03 2 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

Вы имеете в виду, что для MovieClips в массиве, который вы удаляете, вы также хотите удалить их со сцены?

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 
Смежные вопросы