Skip to main content
Participant
Jun 9, 2016 3:36 PM UTC
Question

Loop Animate CC timeline X times and stop

I'm trying to loop the timeline a few times and stop. All the help files I have found so far do not work. Anyone have any ideas?

This topic is closed to new replies. Start a new post to keep the conversation going.

11 replies

Inspiring
Jun 9, 2016 3:59 PM UTC

Another time, try to search forum

Put this code on last frame. This is sample for 3 loops.

if(!this.alreadyExecuted){

this.alreadyExecuted=true;

this.loopNum=1;

} else {

this.loopNum++;

if(this.loopNum==3){

this.stop();

}

}

Translate
Legend
Jun 9, 2016 5:17 PM UTC

You can do it in a lot less code than that:

  1. if (!this.looped) this.looped = 1; 
  2. if (this.looped++ > 3) this.stop(); 

Put the code wherever you want it to stop, set the 3 to the desired loops.

Strange how often this specific simple question comes up.

Translate
just.emma
Inspiring
Jun 9, 2016 8:16 PM UTC

I mentioned this in another thread with the same subject but I'll add it here as well... that code is more concise but I would change it to:

if (!this.looped) this.looped = 1;

if (this.looped++ == 3) this.stop();

(== instead of >) so that it stops at exactly at a specific number of loops.  Your example loops 4 times instead of 3.

Translate