Skip to main content
Uvox1
Known Participant
September 2, 2021
Question

Problem currentFrame in animate CC (html5)

  • September 2, 2021
  • 1 reply
  • 341 views

Hello,

I have a request for help. Below is a video showing my problem. At the first table, which shows me the number of people, it is converted into spoons etc., but when I get out the number of people, instead of counting 1 .. 2 .. 3 .. 4. 5 .. shows 4, 5. So not consecutively. Does anyone know how I can improve? Sorry if I wrote something inaccurate or unclear - I am deaf.

 

https://we.tl/t-o0atg6dynG - recipe.fla

This topic has been closed for replies.

1 reply

JoãoCésar17023019
Community Expert
Community Expert
September 2, 2021

Hi.

 

This issue happens because in HTML5 Canvas documents instances from other frames are not actually destroyed but they are rather only removed or added from the display list. In this way, when a frame is revisited, event listeners are added again.

 

One way to fix this is just to check for a boolean flag in that specific frame so that we know if the frame is being revisited. Like this:

 

 

if (!this.frame0Started)
{
    this.stop();
    this.recipe_coffee.addEventListener("click", click_recipe_coffee.bind(this));
    this.frame0Started = true;
}

 

 

 

I also set the property autoReset to true for the how_many_person instance so that everytime you go to the frame 1 of the main timeline the instance will revert to frame 0.

 

FLA download:

https://drive.google.com/file/d/1qIyl_nnck9Nr6CwFSV83WjF99BWYDX8A/view?usp=sharing

 

Please let us know if you need further help.

 

Regards,

JC

Uvox1
Uvox1Author
Known Participant
September 2, 2021

Thanks a lot for the clarification. There is still a problem with the number of people (how_many_person). It shows two people, but it should start showing at 1. I'm sending a video.

JoãoCésar17023019
Community Expert
Community Expert
September 2, 2021

Hi again.

 

Did you set the autoReset property of that Movie Clip instance to true?