Copy link to clipboard
Copied
I posted this question on Stack Overflow, but didn't get an answer, so I'm re-posting here as it has to do with Animate and binding event listeners to functions.
Copy link to clipboard
Copied
Hi.
I tested your code and it seems everything is working fine.
Can you provide more details?
Regards,
JC
Copy link to clipboard
Copied
So, in the timeline, the code is in frame 1. If you click either button, it sends you to either frame 5 or frame 10. There's a back button there that sends you to frame 1. Clicking the function on the second button fires the code of the first button.
Copy link to clipboard
Copied
Thanks for the info.
I can't still reproduce the issue.
Would you mind sharing your FLA?
Copy link to clipboard
Copied
I get an error when attaching the file via this forum. Try this link: https://www.dropbox.com/s/6grlzfvijt4tejl/interactive-questions.fla?dl=0
Copy link to clipboard
Copied
Thanks for the file.
Your first back button sends the main timeline to the "one" label and the second back button sends the main timeline to the "bantha" label. Is this correct or should both back buttons send the main timeline to the "one" label?
Copy link to clipboard
Copied
Ah, I updated that, but that's not the issue. If you click Back, it sends you to frame 1 "one" and when you click on the image of R2D2, it goes to the C-3PO frame "rocks".
Copy link to clipboard
Copied
No problem.
I changed to "one" here but everything continues to work as expected.
Is there a chance you're getting the impression that you're going to the same label because both have the same title ("C-3PO")?
Copy link to clipboard
Copied
Just reviewing the code:
this.c3po.addEventListener("click", choice1.bind(this));
this.r2d2.addEventListener("click", choice2.bind(this));
// Function that moves the timeline. In JS, it starts at 0
function choice1() {
this.gotoAndStop("bantha");
}
function choice2() {
this.gotoAndStop("rocks");
}
When clicking on R2, it should go to "rocks", but it goes to "bantha" instead, IF you've already gone to "bantha" and have clicked the Back button. I'm testing in Google Chrome.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
OMGosh! You're right! Thank you so much!
Copy link to clipboard
Copied
Excellent! You're welcome!