2 Replies Latest reply on Dec 11, 2015 5:59 AM by noncoder

    Stop a setTimeout function?

    LordMysterious Level 1

      Hey guys

       

      I have a setTimeout that shows a symbol after ten seconds. However, if the user clicks on a button within those ten seconds, I want the setTimeout to stop.

       

      So far I have this code to set up the setTimeout in the click tab of the stage:

       

      if (playing)

      {

           timerName= setTimeout(function() {

           sym.$("buttonName").show();

           }, 10000);

      }

       

      Now this works a treat, however, I have this line to stop it, called by another function:

       

      clearTimeout(timerName);

       

      However, it's not working

       

      Where am I going wrong?

       

      Cheers