AS3 - 在完成之前快速重复MovieClip

时间:2011-01-05 22:43:55

标签: flash actionscript-3 animation repeat

我有一个动画(箭头跟随地图上的路径),我需要它每秒重复大约10次,以便沿着它们的路径有无尽的箭头流。

如何重复影片剪辑来实现此目的?

3 个答案:

答案 0 :(得分:1)

如果您的MovieClip是路径后面的单箭头,则需要定期实例化多个MovieClip,以便创建连续的箭头流。

  private var timer:Timer = new Timer( 100 );

  private function init():void
  {
      timer.addEventListener( TimerEvent.TIMER , createArrow );
      timer.start();
   }

  private function createArrow( event:TimerEvent ):void
  {
      var arrowMc:MovieClip = new ArrowMc();
      //here you should add a Complete Event listener
      //so that when the MovieClip is complete
      //you can remove it from the stage...
      //for this to work your arrowMc should dispatch a Complete
      //Event on the last frame!
      addChild( arrowMc );
  }

或者,根据您的动画,您可以简单地实例化固定数量的动画MC并让它们循环播放。与上面相同,如果您的动画是沿路径移动的单个箭头,请通过设置Timer的限制来实例化固定数字

   private var timer:Timer = new Timer( 100  , 10);
   //etc...

答案 1 :(得分:0)

使用Timer调用以固定间隔为箭头设置动画的功能,或者如果您一次只需要一个箭头,则在动画结束时调度Event,并{{3调度事件时会调用你的函数。

答案 2 :(得分:0)

这是一个非常古老的问题,但这是我对此的回答。 MC是使用引导层的基本动画。 我将MC放在舞台上多次,然后使用间隔以1秒的间隔重复MC。 “redBox”是将MC导出到actionscript时使用的类名。

var redBtn:redBox;

function attachRedBoxes () {
for (var i:Number = 0; i < 5; i++) {
    redBtn = new redBox ();
    redBtn.ID = i;
    redBtn.name = "button_" + i;
    addChild (redBtn);

}
}


setInterval(attachRedBoxes,1000); 
相关问题