Skip to main content
richardn51689295
Participant
April 25, 2018
Answered

Two buttons, one doesn't work

  • April 25, 2018
  • 2 replies
  • 226 views

So I have two buttons on two different layers and I created each button separately to avoid any double instance issues. I am working in HTML 5 and in my script I have the function for both buttons on the same script frame.

this.stop();

this.path1.addEventListener("click", path1Clicked.bind(this));

function path1Clicked()

{

this.gotoAndPlay(2304);

}

this.path2.addEventListener("click", path2Clicked.bind(this));

function path2Clicked()

{

this.gotoAndPlay(2304);

}

The path2 button works and goes to frame 2304 when I click on it, however. The path1 button does not work and I still can click it as though its a button, but it doesn't goto frame 2304

    This topic has been closed for replies.
    Correct answer JoãoCésar17023019

    Hi.

    I tested your code and it works.

    Please double check your instances names.

    2 replies

    richardn51689295
    Participant
    April 25, 2018

    Thanks, something with the instances. I had to remake the buttons and that might of caused a double instance name somewhere I couldn't find the same name twice in my library, however. Changing path1 to just path fixed the script and now it works.

    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    April 25, 2018

    Hi.

    I tested your code and it works.

    Please double check your instances names.