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

Animate CC HTML5 Canvas - loop X times and then stop mid animation, not on endframe

New Here ,
Nov 13, 2016 Nov 13, 2016

Copy link to clipboard

Copied

Hi,

Been searching online for hours and can't find an answer to this? Surely other people are having the same problem?

Trying to create a simple HTML5 Canvas ad animation, Adobe CC Animate.

Frame 0 (START)

|

|

Frame 50 (Endframe)

|

|

Frame 60 (Endframe fades out to white so the animation can loop nicely)

The only resources I can find are telling me to put this on the last frame:

if(!this.alreadyExecuted){

this.alreadyExecuted=true;

this.loopNum=1;

} else {

this.loopNum++;

if(this.loopNum==3){

this.stop();

}

}

But this just loops the whole timeline from Frame 0 to 60. That means my endframe would just be a solid white empty panel (the fadeout).

Anyone have any ideas? I think it needs to be something like:

Frame 0 (START)

|

|

Frame 50 (Endframe) If loop =<2, continue playing. If loop = 3, stop here.

|

|

Frame 60 If loop =<2, go to frame 0 + play.

Many thanks in advance!

Lauren

TOPICS
Code , How to

Views

10.1K

Translate

Translate

Report

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

New Here , Nov 13, 2016 Nov 13, 2016

Omg I want to cry, I was so close haha. To be fair, it was 2am. I think my brain stopped working.

Thanks kglad. Legend.

Heads up for others: You still need that gotoandplay on the endframe, to make it loop.

Frame 0 (START)

Frame 50 (Desired Endframe)

if(!this.alreadyExecuted){

this.alreadyExecuted=true;

this.loopNum=1;

} else {

this.loopNum++;

if(this.loopNum==3){

this.stop();

}

}

Frame 60 (Timeline endframe)

this.gotoAndPlay(0);

Votes

Translate

Translate
Community Expert ,
Nov 13, 2016 Nov 13, 2016

Copy link to clipboard

Copied

put that code on line 50.

Votes

Translate

Translate

Report

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 ,
Nov 13, 2016 Nov 13, 2016

Copy link to clipboard

Copied

Omg I want to cry, I was so close haha. To be fair, it was 2am. I think my brain stopped working.

Thanks kglad. Legend.

Heads up for others: You still need that gotoandplay on the endframe, to make it loop.

Frame 0 (START)

Frame 50 (Desired Endframe)

if(!this.alreadyExecuted){

this.alreadyExecuted=true;

this.loopNum=1;

} else {

this.loopNum++;

if(this.loopNum==3){

this.stop();

}

}

Frame 60 (Timeline endframe)

this.gotoAndPlay(0);

Votes

Translate

Translate

Report

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
LEGEND ,
Nov 14, 2016 Nov 14, 2016

Copy link to clipboard

Copied

LATEST

You shouldn't need that code in the last frame if you have the timeline set to loop in the publish settings.

And the code you're using is needlessly verbose. You can accomplish the same thing with just this:

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

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

Votes

Translate

Translate

Report

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