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

At a loss — How do I get my animation to loop a set number of times before stopping?

Explorer ,
Oct 16, 2019 Oct 16, 2019

I'm a beginner. Sorry! But I've created an animation that works. It's simple and very straight forward.

 

But it doesn't do what I want which is to start when I click "Start" then loop three times and stop at the end of the animation at frame 58.

 

Here's what I have:

in Layer 1, frame 1 of the animation I have this:


var _this = this;
_this.stop();

 

In Layer 1, frame 2 and to the end (frame 58 is end) I have this:

 

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

if (this.looped++ > 3) this.gotoAndStop('58');

 

In Layer 2, frame 1 and to the end I have this (and a "Start" button):


var _this = this;
_this.button_2.on('click', function(){
_this.gotoAndPlay('2');
});

 

Animation starts when I click "Start" but it only plays once, then goes back to beginning and stops. It seems my "Stop" in Layer 1, frame 1 overrides the loop command? But what do I do to prevent the animation to auto play on load if I don't have a Stop action in there?

TOPICS
ActionScript , Code , How to , Timeline
6.0K
Translate
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

LEGEND , Oct 17, 2019 Oct 17, 2019
Translate
LEGEND ,
Oct 17, 2019 Oct 17, 2019
Thanks for you kind words. I updated the file. You can download the new version.
Translate
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
Explorer ,
Oct 17, 2019 Oct 17, 2019
THANK YOU! I tweaked it a tiny bit so it stops on the last frame (second to the last actually, last one didn't work). http://1cc.2b1.myftpupload.com/gstest/1_1_v10_working.html
Translate
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 ,
Oct 18, 2019 Oct 18, 2019
LATEST

Glad I could help! Good lluck on your project. 🙂

Translate
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