Copy link to clipboard
Copied
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.
if you want to stop your timer, use its stop() method:
timer.stop();
p.s when using the adobe forums, please mark helpful/correct responses, if there are any.
Copy link to clipboard
Copied
:
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
if(this.currentFrame<this.currentScene.numFrames){
this.gotoAndStop(this.currentFrame+5);
} else {
// first frame in this scene. if this needs to work for more than one scene you can loop through all your scenes at the start and determine all the first and last frames.
this.gotoAndStop(whatever);
}
}
Copy link to clipboard
Copied
I only want the first scene to loop. I tried stop at the frame number and also stop at the frame number and scene and it still continues to the next scene.
stop();
var timer:Timer = new Timer(3000,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
if(this.currentFrame<this.currentScene.numFrames){
this.gotoAndStop(this.currentFrame+5);
} else {
// first frame in this scene. if this needs to work for more than one scene you can loop through all your scenes at the start and determine all the first and last frames.
this.gotoAndStop(50);
}
}
stop();
var timer:Timer = new Timer(3000,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
if(this.currentFrame<this.currentScene.numFrames){
this.gotoAndStop(this.currentFrame+5);
} else {
// first frame in this scene. if this needs to work for more than one scene you can loop through all your scenes at the start and determine all the first and last frames.
this.gotoAndStop(50, "Welcome");
}
}
Copy link to clipboard
Copied
what's the last frame number of the first scene?
Copy link to clipboard
Copied
The last frame number of the first scene (which is named "Welcome") is 50.
Copy link to clipboard
Copied
then you shouldn't be 'looping back to that frame. use:
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
if(this.currentFrame<this.currentScene.numFrames){
this.gotoAndStop(this.currentFrame+5);
} else {
// first frame in this scene.
this.gotoAndStop(1);
}
}
p.s when using the adobe forums, please mark helpful/correct responses, if there are any.
Copy link to clipboard
Copied
thank you for your code.
I have everything in one scene now and the below code works great with for a loop with the code in Frame 55 to repeat. My problem now is that once I click on any of the buttons the reset of the frames not in the first 55 is still using the timer and advancing to the next frame. I can click through buttons before the timer advances but I need to know how to stop the time so it will not work past frame 55. Any Ideas?
Code in Frame 55:
stop();
{
if (currentFrame == 55) {
gotoAndPlay(1);
}
}
Code in first Frame:
import flash.display.Scene;
import flash.events.TimerEvent;
stop();
var called:Boolean;
if (!called) {
var timer:Timer = new Timer(500,0);
timer.addEventListener(TimerEvent.TIMER, timerHandler);
timer.start();
called = true;
}
function timerHandler(event:TimerEvent):void {
if (this.currentFrame != 55) {
this.nextFrame();
} else {
this.stop();
}
}
Copy link to clipboard
Copied
if you want to stop your timer, use its stop() method:
timer.stop();
p.s when using the adobe forums, please mark helpful/correct responses, if there are any.
Copy link to clipboard
Copied
For this code to work, you need to empty the first frame and place all the photos a frame ahead. Then, place this code on the first frame. DONE!
If you need more help, I'll try to answer it the fastest I can.
Oh, and I could actualy make your photos fade out and fade in as they rotate from frame to frame, it would be awesome. Just tell me if you want me to do it. Good luck
import flash.display.Scene;
import flash.events.TimerEvent;
stop();
var timer:Timer = new Timer(2000,0);
timer.addEventListener(TimerEvent.TIMER, timerHandler);
timer.start();
function timerHandler(event:TimerEvent):void {
if (this.currentScene.name == "Scene 1") {
if (this.currentFrame != this.currentScene.numFrames) {
this.nextFrame();
} else {
this.gotoAndStop(2);
}
}
}
nextFrame();
Find more inspiration, events, and resources on the new Adobe Community
Explore Now