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...
this is correct, and on clicking the green switch button, they are taken to frame 20...
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!
frame 1 is actually the 2nd frame. you probably want:
this.gotoAndStop(0)
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.
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);
}
Copy link to clipboard
Copied
frame 1 is actually the 2nd frame. you probably want:
this.gotoAndStop(0)
Copy link to clipboard
Copied
even with that code, nothing happens when I click the pink button
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!!
Copy link to clipboard
Copied
your welcome.
(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)