Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Going back and forth through the Main Timeline

Community Beginner ,
Aug 28, 2018 Aug 28, 2018

Dear all,

I'm working on a HTML5 canvas.

I have two buttons.

By clicking on the first button (BUTTON 1) I go to the next fifth frame and stop there.

By clicking the other button (BUTTON 2) I go back to the first frame (number 0) wherever currentframe the animation is.

Actually, I used this codes:

BUTTON 1:

exportRoot.BUTTON 1.addEventListener("click", fl_ClickToGoToAndStopAtFrame_1.bind(this));

function fl_ClickToGoToAndStopAtFrame_1() {

    exportRoot.gotoAndStop(exportRoot.currentFrame + 5);

}

BUTTON 2:

exportRoot.BUTTON 2.addEventListener("click", fl_ClickToGoToAndStopAtFrame_2.bind(this));

function fl_ClickToGoToAndStopAtFrame_2() {

    exportRoot.gotoAndStop(0);

}

However it happens that when I click on BUTTON 2 it's ok: the animation goes to frame 0

BUT

afterwards, if I newly click on BUTTON 1 it skips several frames: it does not go to frame 5.

What happens?

Do I have to reset the timeline when I go back to frame 0?

I don't really know what happens

Thank you in advance

1.2K
Translate
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

Community Expert , Aug 29, 2018 Aug 29, 2018

BUTTON1's code advances by 5 frames: exportRoot.gotoAndStop(exportRoot.currentFrame + 5);

it does not go to the 5th or so frame.  that would be something like: exportRoot.gotoAndStop(5);

Translate
Community Expert ,
Aug 29, 2018 Aug 29, 2018

BUTTON1's code advances by 5 frames: exportRoot.gotoAndStop(exportRoot.currentFrame + 5);

it does not go to the 5th or so frame.  that would be something like: exportRoot.gotoAndStop(5);

Translate
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
Participant ,
Dec 22, 2018 Dec 22, 2018
LATEST

I think the problem is,  when you reach frame 0  again you reach the frame where the functions are defined.

So the function is defined once more every time you reach frame 0

You have to put the functions in the global Script and the addEventListener in the first Frame.

If you want to proof whats happening if the functions are in the first frame put a console.log in the functions

console.log(exportRoot.currentFrame);

when you click BUTTON 1 and BUTTON 2 again and again

you will see that the command will be invoked several times

Translate
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