Copy link to clipboard
Copied
I have a curious problem. Some buttons, which are all on separate layers, and some instances of the same button named uniquely, aren't functioning. I have a very simple function I'm trying to accomplish really. Once the button is clicked, the playhead moves to a desired frame and stops there. Some buttons work fine. On this frame, they aren't working.
Here's the code on this frame. I've verified the button names are correct. I used Animate's code authoring feature so eliminate my human factor of mistakes.
this.stop();
this.s1m1_btn.addEventListener("click", fl_ClickToGoToAndStopAtFrame_8.bind(this));
function fl_ClickToGoToAndStopAtFrame_8()
{
this.gotoAndStop(52);
}
this.backBtn.addEventListener("click", fl_ClickToGoToAndStopAtFrame_9.bind(this));
function fl_ClickToGoToAndStopAtFrame_9()
{
this.gotoAndStop(24);
}
You have it going to frames 42 and 52. It should be 41 and 51, because of how frames start at 0 when you run the published files.
Copy link to clipboard
Copied
remove that button from the keyframe that contains that code.
create (using a library symbol or otherwise) the button on that keyframe and assign its name in the properties panel.
retest.
Copy link to clipboard
Copied
Thanks for your quick reply, Gladstein. I tried that yesterday and again just now. The button is on a separate layer than the code. I deleted it. I used a symbol from my library of the button I created yesterday. I gave it another instance name "backBtn21", just so it was different than previous. Still no luck. Any more ideas?
Copy link to clipboard
Copied
Consequently, all of the buttons on this frame are not working. All are on separate layers.
Copy link to clipboard
Copied
did you change your code?
Copy link to clipboard
Copied
Yes. I did change the code to reflect the new button instance name.
Copy link to clipboard
Copied
kglad, you had originally said to "remove that button from the keyframe that contains that code". Are you asking if the button is on the same frame and layer that has the code? I'm assuming that buttons should not be placed on the same layer as the code itself. Is that correct?
Copy link to clipboard
Copied
Code can go on any layer. I think kglad was suggesting to recreate the button, in the hope that something is wrong with the current one.
Copy link to clipboard
Copied
I've recreated the buttons several times. I think there's something glitchy going on, or I quite possibly might be losing my mind. Would anyone be willing to look at the files?
Copy link to clipboard
Copied
Yes, either post a link to the working (non-working) published files, or upload the FLA somewhere.
Copy link to clipboard
Copied
I emailed you a link to my drop box. Let me know if you don't have it. Thanks!
Copy link to clipboard
Copied
You have it going to frames 42 and 52. It should be 41 and 51, because of how frames start at 0 when you run the published files.
Copy link to clipboard
Copied
When debugging, always test your assumptions.
You assume that "this.s1m1_btn" is the correct reference to use for addEventListener. Is it? Stick an alert(this.s1m1_btn); after it. And so on for each one.
You assume the event handlers are actually being called. Are they? Stick an alert(this) statement inside them.
Copy link to clipboard
Copied
Thanks so much, Colin! It works now!