0

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

更具体地说,我正在编写一个益智游戏,每次我进入游戏时,移动其中一个片段并按下 MovieClip 后退按钮,下次我进入同一个游戏时,我仍然会看到我离开它的片段,我想要电影剪辑重新开始到它的原始位置。我在这里做错了什么?不介意变量,这里的重点是当我点击每个功能时,我如何重新启动对我开始游戏时它们的引用?谢谢。

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);
    } 

}
4

1 回答 1

0

您可以在单击后保存原始位置和存储库,或者您可以每次创建和销毁影片剪辑。简单地再次添加到显示列表是不够的,因为它的位置保存在 mc 本身上。

于 2012-07-14T12:00:48.270 回答