11 Replies Latest reply on May 16, 2017 6:12 AM by Loic.Aigon

    addEventListener not working when there's loop

    eboda_snaf Level 1

      Hi there,

       

      addEventListener seems not working when there's a loop in the program. Any way to solve this?

      Thank you...

       

      ;---------------------------------------------------------------------------------------

      var myWin = new Window ( "window", "LOOP TESTING.." );
      var myTxt = myWin.add("statictext", undefined, "Testing.....................");
      var cancel_button = myWin.add ("button", undefined, "Cancel");
      cancel_button.addEventListener ("click", function () {alert("cancel_button.addEventListener");myWin.close();exit();});
      myWin.show();

      for (var i =0; i<20;i++){
          myTxt.text = String("TEsting: " + i);
          $.sleep(100);  
      }

      myWin.close();
      exit();