mardi 30 juin 2015

Check if hitTestObject finished with all the elements of an array

I have an array with seven movieclips that hitTestObject a movieclip called ousiastikaChest. That's works fine. I want to check if all elements of that array had hitTestObject so a well done message to appear. This part of my code is wrong. Can anyone help me? Thank you

This is my code

 var circles:Array = [ous1,ous2,ous3,ous4,ous5,ous6,ous7];
 for each(var circleMC:MovieClip in circles)
 {
     circleMC.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
     circleMC.addEventListener(MouseEvent.MOUSE_UP, dropIt);
     circleMC.startX = circleMC.x;
     circleMC.startY = circleMC.y;
}

 function pickUp(event:MouseEvent):void
 {
     event.target.startDrag(true);
     event.target.parent.addChild(event.target);

 }

function dropIt(event:MouseEvent):void
 {
     event.target.stopDrag();

     if(event.target.hitTestObject(ousiastikaChest)){
         event.target.buttonMode = false;
         event.target.alpha = 0 
         event.target.x = ousiastikaChest.x;
         event.target.y = ousiastikaChest.y;
         ousiastikaChest.gotoAndPlay(2);
    }
    else
     {
         event.target.x = event.target.startX;
         event.target.y = event.target.startY;
         event.target.buttonMode = true;
    }
 }
 //problem with that part of the code
 for(var i:int = 0; i<circles.length;i++){
      if(circles[i].hitTestObject(ousiastikaChest)){
         feedback.text="Well Done";
      }
 } 

Aucun commentaire:

Enregistrer un commentaire