1 Reply Latest reply on Sep 17, 2009 10:56 AM by Ned Murphy

    setInterval/clearInterval Problem

    raslate

      Hi, I'm trying to make a simulator with a speedometer controlled by a brake pedal and an accelerator pedal using the following code:

       

      function needleMovementDown(){
            _root.needle_mc._x-=1;
            if (_root.needle_mc._x<142) {
                 clearInterval (_root.needleIntervalDown);
            }
      }
      this.brakePedal_mc.onPress = function () {
            clearInterval (_root.needleIntervalUp);
            _root.needleIntervalDown = setInterval(needleMovementDown, 5);
      }
      this.brakePedal_mc.onRelease = function () {
           clearInterval (_root.needleIntervalDown);
      }
      function needleMovementUp(){
            _root.needle_mc._x+=1;
            if (_root.needle_mc._x>414) {
                 clearInterval (_root.needleIntervalUp);
            }
      }
      this.accelerator_mc.onPress = function () {
            clearInterval (_root.needleIntervalDown);
            _root.needleIntervalUp = setInterval(needleMovementUp, 5);
      }
      this.brakePedal_mc.onRelease = function () {
           clearInterval (_root.needleIntervalUp);
      }

       

      I'm pretty sure I have a targeting problem because the clip moves but it doesn't stop with the onRelease function.  I would appreciate any help you could provide!!!