Array manipulation
Hi,
I like to know whether the array can be manipulated better than below code.
My game has buttons called ADD and UNDO . When I press ADD it will create some shapes as movieclip, which will be saved in an array for undo. UNDO button is to remove the created shapes in the order it was created.
For this, whenever shape was created ill push them in an array. For UNDO ill pop () the array and remove them.
Now I need to add a new button called DELETE, which will remove the selected shapes. For that I have added the below code, it works fine. I like know without this loop can I delete
below is my code,
Var shapeArr:Array = new Array();
ADD :
- shapeArr.push(myMc);
UNDO :
removeChild(shapeArr.pop())
for DELETE:
shapeArr.reverse();
for (var i=0; i< shapeArr.length; i++)
{
If(shapeArr.name == removeMc.name){
shapeArr.splice(i,1);
}
}
shapeArr.reverse();
thanks in advance
