Skip to main content
Known Participant
January 20, 2021
Question

buttons click

  • January 20, 2021
  • 3 replies
  • 217 views

why when i am click on button to run function the function run twies?

 

    This topic has been closed for replies.

    3 replies

    Yigal0D4BAuthor
    Known Participant
    January 20, 2021

    i tried to do this but it is not working

    here is the original cod 

    where shuld i can use your cod?

     

    in this link you can see asample of counting 

    http://hebrewgames.org/test/test1.html

     

    when click + or _ it is counting ok

    when click NEXT PAGE

    when click + or - it is counting not ok it is look like repeating the function.

     

    code:

    frame 0:

    this.stop();

    this.counter=0;

     

    this.plus_bt.addEventListener("click", countUp.bind(this));

    function countUp()
    {
    this.counter= this.counter+1;
    this.countTx.text=this.counter;
    }

     

    this.minus_bt.addEventListener("click", countDown.bind(this));

    function countDown()
    {
    this.counter= this.counter-1;
    if (this.counter<0){this.counter=0}
    this.countTx.text=this.counter;
    }

    this.nextPage_bt.addEventListener("click", nextP.bind(this));

    function nextP()
    {
    this.gotoAndPlay(1);
    }


    this.prevPage_bt.addEventListener("click", prevP.bind(this));

    function prevP()
    {
    this.gotoAndPlay(0);
    }

     

     

    frame1:

    this.stop();

    Yigal0D4BAuthor
    Known Participant
    January 20, 2021

    Thank you!

     

    ishuld do this code for every button? 

    JoãoCésar17023019
    Community Expert
    Community Expert
    January 20, 2021