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

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

450

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

Votes

Translate

Translate
Community Expert ,
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

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

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 ,
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?

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 ,
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

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 ,
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?

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

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

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

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

Copy link to clipboard

Copied

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

Copy link to clipboard

Copied

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

 

 

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

Copy link to clipboard

Copied

LATEST

Excellent! You're welcome!

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