Skip to main content
Participant
Sep 1, 2022 9:37 AM UTC
Question

How do i set the frame loop time?

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 is closed to new replies. Start a new post to keep the conversation going.

    5 replies

    kglad
    Community Expert
    Community Expert
    Sep 1, 2022 3:02 PM UTC

    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.

    Translate
    Chris_nohAuthor
    Participant
    Sep 2, 2022 6:00 AM UTC

    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?

    Translate
    kglad
    Community Expert
    Community Expert
    Sep 2, 2022 3:39 PM UTC

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

    Translate