dimanche 29 novembre 2015

Removing items of an array from stage in as3- one each time

I am trying to remove movieclips of an array from the stage. I want to remove one item of the circles array every time there is a click in an item from the square array. I wrote this code but something is missing and i can not figure it out because all the items of the circles array disappear from stage with the first click. Can you please help me.

var circles:Array = [circle1, circle2, circle3, circle4,circle5, circle6];
var counter:int = 0; 


var square:Array = new Array   (square1,square2,square3,square4,square5,square6,square7,square8,square9,square10,square11,square12,square13,square14,square15,square16,square17,square18,square19,square20,square21);
  for(var i:int = 0; i < square.length; i++)
{
    square[i].addEventListener(MouseEvent.CLICK, clickTomove);
    function clickTomove(e:MouseEvent):void
{
    trace("square");
    var len:int=circles.length;
    for(var o:int=0; o<circles.length; o++)
    this.removeChild(circles[o]); 
    circles.splice(o,1);
}
}

Aucun commentaire:

Enregistrer un commentaire