Skip to main content
Participant
February 7, 2018
Question

Help! How can I exit loop after looping certain times?

  • February 7, 2018
  • 2 replies
  • 1470 views

Hi guys,

I'm sorry if this question was asked before but I really couldn't find an answer to this:

How can I loop a banner from frame 1 to frame 255 three times and when it's playing the 4th time it should play until frame 256 which is the final frame.

Thanks a lot,

Michael

This topic has been closed for replies.

2 replies

Inspiring
February 7, 2018

or just on 254

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

if (this.looped++ == 3) this.gotoAndStop(255);

Legend
February 7, 2018

That wouldn't send the timeline back to frame one. The fixed version would be:

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

if (this.looped++ < 3) this.gotoAndPlay(1);

On the second-to-last frame, whatever it happens to be.

Inspiring
February 7, 2018

Yes, my mistake

JoãoCésar17023019
Community Expert
Community Expert
February 7, 2018

Hi.

Use this code:

Frame 1 (0):

if (this.resume >= 0)

    this.resume++;

else

    this.resume = 0;

Frame 255 (254):

if (this.resume < 3)

    this.gotoAndPlay(0);

else

    this.gotoAndStop(255);

Regards,

JC

Participant
February 7, 2018

Amazing that works! Thanks so much!

Cheers,

Michael

JoãoCésar17023019
Community Expert
Community Expert
February 7, 2018

You're welcome!