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

Animate CC Loop

New Here ,
Nov 15, 2016 Nov 15, 2016

Copy link to clipboard

Copied

I am trying to create a loop using the below:

"loop" is a frame label 1 frame after the below on the main timeline.

Can someone find what is keeping this from working?

Thank you!

var i = 0;

i++;

if (i < 2) {

this.play("loop");

} else if (i > 2) {

  this.stop();

}

Views

1.2K

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

Thank you for the tips @ClayUUID. You got me on the right track. After making the adjustments you suggested, the loop works as expected.

/*defined i=0 in first frame

placed this.gotoAndPlay("restart"); on last frame

placed "restart" label on first frame */

if (i < 3) {

i++;

} else if (i == 3) {

  this.stop();

}

ClayUUID  Nov 15, 2016 8:28 PM (in response to Tony Dilger)

ANSWER!

You initialize i to zero every time you enter the frame.

The variable i only exists in that frame.

The conditional logic doesn't acc

...

Votes

Translate

Translate
LEGEND ,
Nov 15, 2016 Nov 15, 2016

Copy link to clipboard

Copied

You initialize i to zero every time you enter the frame.

The variable i only exists in that frame.

The conditional logic doesn't account for i being equal to 2.

There's no such function as .play().

There's no need to use a frame label when you're just advancing to the next frame.

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
Enthusiast ,
Nov 16, 2016 Nov 16, 2016

Copy link to clipboard

Copied

I use this in my banner ads to loop the creative 2x:

if(!this.alreadyExecuted){

this.alreadyExecuted=true;

this.loopNum=1;

} else {

this.loopNum++;

if(this.loopNum==2){

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

Copy link to clipboard

Copied

I don't know why people are still using that ungainly code when a perfectly functional two-liner has been posted here many times:

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

if (this.looped++ > 2) 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
Enthusiast ,
Nov 16, 2016 Nov 16, 2016

Copy link to clipboard

Copied

sorry clay it wasnt to your standards, I will use your updated code from now on.

Cheers

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

Copy link to clipboard

Copied

LATEST

Thank you for the tips @ClayUUID. You got me on the right track. After making the adjustments you suggested, the loop works as expected.

/*defined i=0 in first frame

placed this.gotoAndPlay("restart"); on last frame

placed "restart" label on first frame */

if (i < 3) {

i++;

} else if (i == 3) {

  this.stop();

}

ClayUUID  Nov 15, 2016 8:28 PM (in response to Tony Dilger)

ANSWER!

You initialize i to zero every time you enter the frame.

The variable i only exists in that frame.

The conditional logic doesn't account for i being equal to 2.

There's no such function as .play().

There's no need to use a frame label when you're just advancing to the next frame.

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