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

Buttons to go to frame number, not working. please help?

Explorer ,
Sep 28, 2017 Sep 28, 2017

Copy link to clipboard

Copied

Hello,

So, basically I am fairly new to Animate CC, and I am testing a basic html5 canvas. So I have two buttons, next to each other designed to look like a switch. When clicked it takes you to frame 20, where a different image will appear (in my testing case a red square), and I put a different button on the other side of the 'switch'. However, I can't get this second button to work, and when clicked nothing happens, when I would like it to take the user back to the first frame where the blue square is shown.

This is the opening screen that the user will find...

Screen Shot 2017-09-28 at 20.18.56.png

this is correct, and on clicking the green switch button, they are taken to frame 20...

Screen Shot 2017-09-28 at 20.19.05.png

which is also correct. However this is where I get a problem. I then want the pink switch button to take the user back to the beginning frame. When testing this html5 in the browser, a white click hand does appear over the pink button, but nothing happens when I click it.

Please could someone help with this and explain where I am going wrong? It seemed like such a simple thing to do but for some reason I can't get it to work. Any suggestions would be greatly appreciated!!

Thank you!

Views

495

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

Community Expert , Sep 28, 2017 Sep 28, 2017

frame 1 is actually the 2nd frame.  you probably want:

this.gotoAndStop(0)

Votes

Translate

Translate
Community Expert ,
Sep 28, 2017 Sep 28, 2017

Copy link to clipboard

Copied

where's the code for that pink button?

it should be on the first keyframe where the pink button appears and there should be no other keyframes that contain the pink button (during debugging).

also, your code needs to be correct and there are numerous ways this could fail.  to be sure, you should be using a developers console to test and start by seeing if there are any errors when clicking the pink button.

Votes

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 ,
Sep 28, 2017 Sep 28, 2017

Copy link to clipboard

Copied

so this is my very simple timeline. The pink button first appears in frame 20.

I have this code on frame 1;

this.stop();

this.greenbutton.addEventListener("click", fl_ClickToGoToAndStopAtFrame_2.bind(this));

function fl_ClickToGoToAndStopAtFrame_2()

{

  this.gotoAndStop(20);

}

And this code at frame 20;

this.pinkbutton.addEventListener("click", fl_ClickToGoToAndStopAtFrame.bind(this));

function fl_ClickToGoToAndStopAtFrame()

{

  this.gotoAndStop(1);

}

Screen Shot 2017-09-28 at 21.12.07.png

Votes

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
Community Expert ,
Sep 28, 2017 Sep 28, 2017

Copy link to clipboard

Copied

frame 1 is actually the 2nd frame.  you probably want:

this.gotoAndStop(0)

Votes

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 ,
Sep 28, 2017 Sep 28, 2017

Copy link to clipboard

Copied

even with that code, nothing happens when I click the pink button

Votes

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 ,
Sep 28, 2017 Sep 28, 2017

Copy link to clipboard

Copied

Oh, i have just changed the go to in the coding in frame one to this.gotoAndStop(19) instead of 20 and now it works perfectly.

Thanks so much for your help!!

Votes

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
Community Expert ,
Sep 28, 2017 Sep 28, 2017

Copy link to clipboard

Copied

LATEST

your welcome.

(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)

Votes

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