【问题标题】:Flash/ActionScript 3.0 How can I continually loop frames in same scene without going to next sceneFlash/ActionScript 3.0 如何在同一场景中连续循环帧而不转到下一个场景
【发布时间】:2014-10-04 22:05:38
【问题描述】:

如何在同一场景的每一帧中连续循环播放帧,每帧暂停 20 秒,而不转到下一个场景?这些帧中有其他场景的按钮。下面的效果很好,直到我在场景一的最后一帧,然后它进入下一个场景并播放。我怎样才能让场景一连续循环。

stop();

var timer:Timer = new Timer(20000,0);//<--
timer.addEventListener(TimerEvent.TIMER, timerHandler);
timer.start();

function timerHandler(event:TimerEvent):void {
    this.nextFrame();
    //or if you want to jump e.g 5 frames
    this.gotoAndStop(this.currentFrame+5);
}

感谢您的帮助。

【问题讨论】:

  • 如果我的回答解决了您的问题,请考虑将其标记为已接受的答案。

标签: actionscript-3 flash


【解决方案1】:

你只需要检查一下你的下一帧是否会是最后一帧:

function timerHandler(event:TimerEvent):void {
    if(this.currentFrame + 1 <= this.totalFrame){ //if your desired destination is less than the total frames, then your safe to goto to the nextFrame - replace the +1 with however many frames you want to skip
        this.nextFrame();
    }else{ //if not, reset back to frame one (loop)
        this.gotoAndStop(1);
    }
}

【讨论】:

  • 我认为 gotoAndPlay 是让事情继续下去的必要条件
  • @RST 他们正在使用计时器来推进时间线
猜你喜欢
  • 1970-01-01
  • 2018-09-07
  • 2020-04-01
  • 1970-01-01
  • 1970-01-01
  • 2017-07-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多