如何重新启动flash as3 movieclip的引用?

时间:2012-07-14 11:14:10

标签: actionscript-3 flash movieclip

我使用各种movieClip和movieClip按钮 - 所有MC都通过代码插入,舞台上什么都没有。 每次按钮的eventListener被触发时,我调用下一个函数,我在那里添加下一个movieClip,然后我想删除之前使用的MovieClip的引用。

更具体地说我正在写一个益智游戏,每次我进入游戏,移动其中一个片段并按下MovieClip后退按钮,下次我进入同一个游戏时我仍然会看到我离开它的那个片段我希望movieClip重新启动到其原始位置。 我在这做错了什么? 不介意vars这里的重点是当我点击每个功能时我重新启动对我开始游戏时的参考的引用? 感谢。

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 个答案:

答案 0 :(得分:0)

您可以保存原始位置并重新点击后退,或者您可以每次创建和销毁动画片段。仅仅添加到显示列表是不够的,因为它的位置保存在mc本身上。