Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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();
}
}
Copy link to clipboard
Copied
You can do it in a lot less code than that:
- if (!this.looped) this.looped = 1;
- 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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
And as I responded last time, that depends on whether you put the code at the beginning or end of the main timeline.
Copy link to clipboard
Copied
It doesn't really seem logical to put it at the beginning of the timeline.
Typically when you loop something, you would want to stop on the end frame with something interesting to look at, some kind of message, or a call to action; not go back to a blank beginning frame before the animation started.
Copy link to clipboard
Copied
Does this work for HTML 5 export?
Copy link to clipboard
Copied
Just try it in HTML 5 export work greats, thx ! 🙂