Multiple event listeners and bind

Explorer ,
Mar 22, 2021 Mar 22, 2021

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.  

TOPICS
Code, How to

Views

135

Likes

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

Adobe Community Professional , Mar 22, 2021 Mar 22, 2021

Likes

Translate

Translate
Adobe Community Professional ,
Mar 22, 2021 Mar 22, 2021

Copy link to clipboard

Copied

Hi.

 

I tested your code and it seems everything is working fine.

 

Can you provide more details?

 

Regards,

JC

Likes

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 ,
Mar 22, 2021 Mar 22, 2021

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.

Likes

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
Adobe Community Professional ,
Mar 22, 2021 Mar 22, 2021

Copy link to clipboard

Copied

Thanks for the info.

 

I can't still reproduce the issue.

 

Would you mind sharing your FLA?

Likes

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 ,
Mar 22, 2021 Mar 22, 2021

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

Likes

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
Adobe Community Professional ,
Mar 22, 2021 Mar 22, 2021

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?

Likes

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 ,
Mar 22, 2021 Mar 22, 2021

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".

Likes

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
Adobe Community Professional ,
Mar 22, 2021 Mar 22, 2021

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")?

Likes

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 ,
Mar 22, 2021 Mar 22, 2021

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. 

Likes

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
Adobe Community Professional ,
Mar 22, 2021 Mar 22, 2021

Copy link to clipboard

Copied

Likes

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 ,
Mar 22, 2021 Mar 22, 2021

Copy link to clipboard

Copied

OMGosh! You're right! Thank you so much!

 

 

Likes

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
Adobe Community Professional ,
Mar 22, 2021 Mar 22, 2021

Copy link to clipboard

Copied

LATEST

Excellent! You're welcome!

Likes

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