Animation run faster when using gotoAndPlay from earlier frame

Explorer ,
Apr 21, 2021 Apr 21, 2021

Copy link to clipboard

Copied

Hello, I don't know what happened but my canvas animation run very fast after I press go back button (gotoAndPlay(0)).

My animation contains sounds, graphics (draw circle, line...), linkages and preload.

Preload load all images and sounds. First part is animation with sound, second part have graphics, linkages.

I have a "Go back" button that allowed to play from the start of first part. And "Go next" that jump straight to second part.

1st run is good. Sound start after each other, animation run at 30FPS. Go next button also run good.

But when I press go back button and play again from frame 0, everything faster than before, sound start even when the previous one haven't end.

I tried looking but found nothing. Please help.

Views

140

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
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Apr 26, 2021 Apr 26, 2021
Amazing tutorial! Thanks a lot! Haha Very good. Here is: https://drive.google.com/file/d/145TWJmVrul2UyRn1fQu9T9_bECA9Rbf5/view?usp=sharing What I did was to check in each frame if the code has already run or not, preventing multiple event listeners of the same type from being added to the same instance. Please let me know if it's working now. Regards, JC

Likes

Translate

Translate
Adobe Community Professional ,
Apr 22, 2021 Apr 22, 2021

Copy link to clipboard

Copied

Hi.

 

It is quite possible that when you press the back button events are being added again and instances added at runtime are not being removed in the way you expect.

 

Can you verify this?

 

Regards,

JC

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
community guidelines
Explorer ,
Apr 22, 2021 Apr 22, 2021

Copy link to clipboard

Copied

Yes, that's might be a problem since I have my code in various frames.
Is there anyway to fix it other than put all code in frame 0? 

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
community guidelines
Adobe Community Professional ,
Apr 22, 2021 Apr 22, 2021

Copy link to clipboard

Copied

I would have to see your code. Do you mind providing it?

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
community guidelines
Explorer ,
Apr 25, 2021 Apr 25, 2021

Copy link to clipboard

Copied

Sorry for late reply, due to some security, I can't send you the file. However, I will try to make a simple file for you.

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
community guidelines
Explorer ,
Apr 25, 2021 Apr 25, 2021

Copy link to clipboard

Copied

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
community guidelines
Adobe Community Professional ,
Apr 26, 2021 Apr 26, 2021

Copy link to clipboard

Copied

Amazing tutorial! Thanks a lot! Haha Very good.

 

Here is:

https://drive.google.com/file/d/145TWJmVrul2UyRn1fQu9T9_bECA9Rbf5/view?usp=sharing

 

What I did was to check in each frame if the code has already run or not, preventing multiple event listeners of the same type from being added to the same instance.

 

Please let me know if it's working now.

 

Regards,

JC

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
community guidelines
Explorer ,
Apr 27, 2021 Apr 27, 2021

Copy link to clipboard

Copied

LATEST

Thanks JC, this work like a charm. I will apply it to the rest of my file.

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
community guidelines