Reputation: 21
How do I continually loop frames with a 20 second pause in each frame from the same scene without going to the next scene? There are buttons for the other scenes in these frames. The below works well until I am at the last frame in scene one, then it goes to the next scene and plays. How can I make scene one a continually loop.
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);
}
Thank you for any help.
Upvotes: 2
Views: 1845
Reputation: 14406
You just need to check and see if your next frame is going to be the last frame:
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);
}
}
Upvotes: 1