0
votes

i use various movieClips with movieClip buttons in them-all MC's are inserted through code,there is nothing on the stage. each time the button's eventListener is trigered i call the next function where i add the next movieClip in line and then i want to remove the reference to the MovieClip i used before.

to be more specific i am writing a puzzle game and each time i enter the game,move one of the pieces and press the MovieClip back button,next time i enter the same game i still see the piece where i left it and i want the movieClip to restart to its original position. what am i doing wrong here? don't mind the vars the point here is how when i click back at each of the functions i restart the references to what they were when i started the game? thanks.

public function start1()
        {

                  //start screen

            addChild(first1);
            first1.start(button name).addEventListener(MouseEvent.CLICK, start); 

        }


    public function back1(even:MouseEvent)
{
removeChildAt(numChildren - 1); //want to remove who ever called back1
start1();
}

    public function start(even:MouseEvent)
{
       /choosing num of pieces

       removeChildAt(numChildren - 1); //want to remove first1
       addChild(level);
       level.back.addEventListener(MouseEvent.CLICK, back1);
       level.sixpieces.addEventListener(MouseEvent.CLICK, sixLevel);

}
  //level choosing
    public function sixLevel(even:MouseEvent)
{   
    removeChildAt(numChildren - 1); //want to remove level
     addChild(clevel);
      clevel.back.addEventListener(MouseEvent.CLICK, back1);
      clevel.easy.addEventListener(MouseEvent.CLICK, function(){Slevel=1;six(even);});
      clevel.med.addEventListener(MouseEvent.CLICK, function(){Slevel=2;six(even);});
      clevel.hard.addEventListener(MouseEvent.CLICK, function(){Slevel=3;six(even);});


}

//game itself
    public function six(even:MouseEvent)
{   
    num=6;
    row1=0;
    row2=1;
    row3=2;
    row4=3;

     removeChildAt(numChildren - 1);
      addChild(full1);

      if(Slevel==1)
      {
          full1.time1.visible=false;
          full1.full.visible=true;
        full1.frame1.visible=false;

      }
    else
     if(Slevel==2)
     {
         full1.full.visible=false;
          myTimer = new Timer(1000,60);
     }
     else
     if(Slevel==3)
     {
          full1.full.visible=false;
           myTimer = new Timer(1000,30);
     }
    if(Slevel!=1)
    {
        Slevel=4;

    }
    full1.back.addEventListener(MouseEvent.CLICK, back1);
    for(a=0;a<6;a++)
    {
        this.locarrs[3][a].addEventListener(MouseEvent.MOUSE_DOWN, Move);
        this.locarrs[3][a].addEventListener(MouseEvent.MOUSE_UP, stopMove);
    } 

}
1

1 Answers

0
votes

You can save the original positions and repos on back click or you could create and destroy the movieclips each time. Simply adding again to the display list is not enough since its position is saved on the mc itself.