0 Replies Latest reply on Jun 23, 2008 10:25 AM by bwebb@sig

    clearInterval not clearing from function

    bwebb@sig
      Ok
      I have a flash script that sets one Interval to run at startup. after a button is clicked I want to clear the first Interval and set a new Interval at a faster rate. Then after a boolean condition I want to clear the second Interval and go back and set the first Interval that runs at a slower rate. I feel pretty confident that it is a scope issue but I cant find it. I can clear the first Interval and set the second fine but after the boolean condition clearInterval() will not clear. The function keeps running. Here is the code.
      =================main=====================================
      var con1:String = "OFF";
      var con2:String = "ON";
      var con3:String = "OFF";
      con_1.ID = con1;//PointID; // Readback status
      con_2.ID = con2;//PointID2; // Start button write bit
      con_3.ID = con3;//PointID3; // Stop button write bit

      var myNum:Number;

      myNum = setInterval(this, "evaluateOutput", 5000); // Set timer to display updated values
      trace(this);
      //********************* Main body functions ***************

      function sendCommand()
      {
      trace(myNum);
      trace(this);
      trace(this.myNum);
      if(con2 == "ON")
      {
      if(con1 == "ON")
      {
      con_2.sendOverride(PointID2,"OFF");
      btn_start.enabled = false;
      btn_stop.enabled = true;
      btn_start.selected = false;
      btn_stop.selected = true;
      clearInterval(_parent.myNumb);
      //this.myNum = setInterval(this, "evaluateOutput", 5000);
      }
      }
      if(con3 == "ON")
      {
      if(con1 == "OFF")
      {
      con_3.sendOverride(PointID3,"OFF");
      btn_start.enabled = true;
      btn_stop.enabled = false;
      btn_start.selected = true;
      btn_stop.selected = false;
      clearInterval(myNumb);
      myNum = setInterval(evaluateOutput, 5000);
      }
      }
      }
      function evaluateOutput() {//When function is called:
      if (con1 == "ON" || con1 > 0)
      {
      btn_start.enabled = false;
      btn_stop.enabled = true;
      btn_stop.selected = true;
      }
      else
      {
      btn_stop.enabled = false;
      btn_start.enabled = true;
      btn_start.selected = true;
      }
      }
      ========================Button==============================
      on (click){//when button is mouse clicked:
      trace(this);
      _parent.con_2.sendOverride(_parent.PointID2,"ON");//send and override with the current point ID and the text in the input box
      clearInterval(_parent.myNum);
      _parent.myNum = setInterval(_parent.sendCommand, 1000);
      trace(this._parent);
      btn_start.enabled = false;
      btn_stop.enabled = false;

      }