Highlighted

Loop the beginning of the animation X times snd then go to the end frame

New Here ,
Jan 28, 2019

Copy link to clipboard

Copied

How do I loop the beginning of the animation and only once it is played make the animation proceed to the end? Lets say I have 5 seconds animation: I want first 3 seconds to loop 3 times and only after it is done I want the animation to be played full (5 seconds). Is there any way to do that?

Adobe Community Professional
Correct answer by JoãoCésar | Adobe Community Professional

Hi.

Put the code below in the end of the loop section. For example: your animation has 5 seconds, so put this code in the 3rd second):

JavaScript code:

if (!this.count)

    this.count = 0;

if (this.count++ < 3)

    this.gotoAndPlay(0);

OR

AS3 code:

if (!this.firstTime)

{

    var count:uint = 0;

    this.firstTime = true;

}

if (count++ < 3)

    gotoAndPlay(1);

But, if you your intended output is a video, I do recommend you to wrap the loop part inside of a Graphic symbol instance and then paste it three times in sequence so that you won't have a hard time exporting your animation later.

I hope this helps.

Regards,

JC

Views

78

Likes

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

Loop the beginning of the animation X times snd then go to the end frame

New Here ,
Jan 28, 2019

Copy link to clipboard

Copied

How do I loop the beginning of the animation and only once it is played make the animation proceed to the end? Lets say I have 5 seconds animation: I want first 3 seconds to loop 3 times and only after it is done I want the animation to be played full (5 seconds). Is there any way to do that?

Adobe Community Professional
Correct answer by JoãoCésar | Adobe Community Professional

Hi.

Put the code below in the end of the loop section. For example: your animation has 5 seconds, so put this code in the 3rd second):

JavaScript code:

if (!this.count)

    this.count = 0;

if (this.count++ < 3)

    this.gotoAndPlay(0);

OR

AS3 code:

if (!this.firstTime)

{

    var count:uint = 0;

    this.firstTime = true;

}

if (count++ < 3)

    gotoAndPlay(1);

But, if you your intended output is a video, I do recommend you to wrap the loop part inside of a Graphic symbol instance and then paste it three times in sequence so that you won't have a hard time exporting your animation later.

I hope this helps.

Regards,

JC

Views

79

Likes

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
Jan 28, 2019 0
Adobe Community Professional ,
Jan 28, 2019

Copy link to clipboard

Copied

Hi.

Put the code below in the end of the loop section. For example: your animation has 5 seconds, so put this code in the 3rd second):

JavaScript code:

if (!this.count)

    this.count = 0;

if (this.count++ < 3)

    this.gotoAndPlay(0);

OR

AS3 code:

if (!this.firstTime)

{

    var count:uint = 0;

    this.firstTime = true;

}

if (count++ < 3)

    gotoAndPlay(1);

But, if you your intended output is a video, I do recommend you to wrap the loop part inside of a Graphic symbol instance and then paste it three times in sequence so that you won't have a hard time exporting your animation later.

I hope this helps.

Regards,

JC

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

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
Reply
Loading...
Jan 28, 2019 0
Advocate ,
Jan 29, 2019

Copy link to clipboard

Copied

Hi João

hope you are well. I can't wrap my head around it. Yesterday I tried to answer this question but gave up because my code was toooo long and wound up. It needed an easy going solution.

How ever I tried your javascript solution and it loops the first part 4times instead of 3.

When playhead reaches this frame

1st time: this.count++ = 1

2nd time: this.count++ = 2

3rd time: this.count++ = 3 -> ergo not smaller than 3, it doesn't fulfill the condition

but it loops a fourth time  - why???

Klaus

Likes

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
Reply
Loading...
Jan 29, 2019 0
Adobe Community Professional ,
Jan 29, 2019

Copy link to clipboard

Copied

Hi, Klaus!

What I understand is that the OP wants the playhead to go from 0 to 3 three times and then again a fourth time but continuing until the end.

Like this:

0 _______________ 3

0 _______________ 3

0 _______________ 3

0 _______________ 3________ 5

Also, please notice that when the check happens, the value is still not incremented.

This...

this.count = 0;

console.log(this.count); // 0

console.log(this.count++); // 0

console.log(this.count); // 1

... is not the same as this:

this.count = 0;

console.log(this.count); // 0

console.log(++this.count); // 1

console.log(this.count); // 1

Please let me know if I missed something or if there's something to add.

Regards,

JC

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

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
Reply
Loading...
Jan 29, 2019 0