Skip to main content
Participant
September 1, 2022
Question

How do i set the frame loop time?

  • September 1, 2022
  • 1 reply
  • 195 views

Hi everyone..

 

i imported pngseq files on animate.

 

I have specified frames that start and end loop in some frames.

 

==========================================

loop start frame

 -> if(!this.loopsPlayed){

         this.loopsPlayed = 0;

 

loop end frame

 -> this.loopsplayed ++;

     if(this.loopsplayed == 5){

          this.loopsplayed = 0;

          return;

} else {

          this.gotoandplay(8);

}

==========================================

My question is,
I want to write a script that exits the loop after playing only for a specified amount of time(3min, 9min, 10min...), not counting up.

 

plz help me. 

 

    This topic has been closed for replies.

    1 reply

    kglad
    Community Expert
    Community Expert
    September 1, 2022

    depending on the precision needed and whether this is as3 or html5, you can use setTimeout, ticker, getTimer and a few other less direct methods.

    Chris_nohAuthor
    Participant
    September 2, 2022

    Thank you for your answer.
    I'm going to use AS3, and could you tell me the example codes of the three (setTimeout, ticker, and getTimer) that you told me?

    kglad
    Community Expert
    Community Expert
    September 2, 2022

    i could give all three, but why?

     

    // start movieclip mc playing, and stop it after t seconds.
    function playForF(mc: MovieClip, t: int): void {
    mc.play();
    mc.stopTime = t+getTimer()/1000;
    trace(getTimer()/1000)
    mc.addEventListener(Event.ENTER_FRAME,timerF);

    }

    function timerF(e: Event): void {
    if(getTimer()/1000>=e.currentTarget.stopTime){
    e.currentTarget.stop();
    e.currentTarget.removeEventListener(Event.ENTER_FRAME,timerF);
    }
    }