Skip to main content
George Bernard
Inspiring
April 22, 2021
Answered

Animation run faster when using gotoAndPlay from earlier frame

  • April 22, 2021
  • 1 reply
  • 504 views

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.

    This topic has been closed for replies.
    Correct answer JoãoCésar17023019

    @JoãoCésar17023019 this is my sample, please have a look

    https://www.dropbox.com/s/rjse976y6izn8hr/sample-fast-animation.rar?dl=0


    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

    1 reply

    JoãoCésar17023019
    Community Expert
    Community Expert
    April 22, 2021

    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

    George Bernard
    Inspiring
    April 22, 2021

    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? 

    JoãoCésar17023019
    Community Expert
    Community Expert
    April 22, 2021

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