0

I'm just a beginner in Javascript, and I'm making simple web canvas in Animate CC with few buttons. I add code and first button (AN_Jar) work perfectly, but second (Home_Jar) doesn't work.

Here it is:

 this.AN_Jar.addEventListener("click", fl_onClick_01.bind(this));

function fl_onClick_01()
{
    this.gotoAndStop(4);
}


this.Home_Jar.addEventListener("click", fl_onClick_home1.bind(this));

function fl_onClick_home1()
{
    this.gotoAndStop(3);
}

What I'm missing? (I had this website in written in actionscript 3 and it work perfectly well.)

1 Answer 1

0

When I run the following code, with two movieclips named on stage with the names in your code, I can see each button being triggered:

    this.AN_Jar.addEventListener("click", fl_onClick_01.bind(this));

function fl_onClick_01()
{
    console.log("bt1 hit")
}


this.Home_Jar.addEventListener("click", fl_onClick_home1.bind(this));

function fl_onClick_home1()
{
     console.log("bt2 hit")
}

This successfully traces "bt1 hit" and "bt2 hit" when I press each button,is there anything else you can tell us that you are doing?

2
  • Check that both buttons on stage have the unique name you think they do, namely Home_Jar and AN_Jar Commented Feb 22, 2018 at 14:07
  • I already solve it with: var that1 = this; this.AN_Jar.addEventListener("click", function () { that1.gotoAndPlay(4); });var that2 = this; this.Home_Jar.addEventListener("click", function () { that2.gotoAndPlay(5); }); - solution by Antti Haapala, in one topic. I don't know, why previous solution doesn't work. (As I said, im very begginer in JS, that I also really don't know, why someone down-vote my question:) Thanks for answer anyway:) Commented Feb 23, 2018 at 1:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.