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.
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
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
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?
Copy link to clipboard
Copied
I would have to see your code. Do you mind providing it?
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.
Copy link to clipboard
Copied
@JoãoCésar this is my sample, please have a look
https://www.dropbox.com/s/rjse976y6izn8hr/sample-fast-animation.rar?dl=0
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
Copy link to clipboard
Copied
Thanks JC, this work like a charm. I will apply it to the rest of my file.