Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How do I continually loop frames with a 20 second pause in each frame from the same scene without going to the next scene?

New Here ,
Aug 11, 2014 Aug 11, 2014

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.

TOPICS
ActionScript
645
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 24, 2014 Aug 24, 2014

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.

Translate
Community Expert ,
Aug 11, 2014 Aug 11, 2014

:

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

}

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 11, 2014 Aug 11, 2014

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

}

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 11, 2014 Aug 11, 2014

what's the last frame number of the first scene?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 12, 2014 Aug 12, 2014

The last frame number of the first scene (which is named "Welcome") is 50.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 12, 2014 Aug 12, 2014

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 24, 2014 Aug 24, 2014

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

}

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 24, 2014 Aug 24, 2014
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 12, 2014 Aug 12, 2014

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines