3 Replies Latest reply on Feb 3, 2012 9:18 PM by kglad

    Timeout / stop(); not functioning properly on timeline

    xcmuddman

      Its been a while! I am back at it again trying to "program" a small demo for a digital gauge for work.

       

      I have some sections that look for a (delayedAction) button press of >1 second or else it goes to a warning keyframe on the timeline. Once at the warning frame it stays for a couple seconds (slideIntervalNum) and then continues playing to the next frame which contains a variable telling it return to the initial frame it was at.

      IF the user taps the button for <1 while at the warning frame they back up another section in the timeline. This is all what i planned for but....

       

      my problem is that when the user consecutively hits the button for less than 1 sec and quickly moves back towards the beginning of the animation / timeline at some point something happens that makes it so that it does not want to obey the stop(); command at all!  It will keep playing forwards frame by frame when no action is taken. And even if a button press of >1 sec is executed to stop and go to the next frame it still wont obey the stop(); command!!!

       

      any suggestions??

       

      some of my code that i am using:

       

      //AT STARTUP:

      stop();

       

      var timeOut:Number;

      var currentFrame:String;

      thisFrame="enter_warning_init";

       

      function showNextSlide()

          {

          clearInterval(slideIntervalNum);

          _root.play();

          }

       

      slideIntervalNum = setInterval(showNextSlide, 100);

       

      //BUTTON Requiring >1 Press

      btn_mode.onPress = function()

          {

          timeOut = setTimeout(delayedAction, 1000);

          btn_mode.onRelease = function()

              {

              clearTimeout(timeOut);

              delete btn_mode.onRelease;

              gotoAndPlay("enter_warning_init");

              }

          }

      //BASIC CODE IN GENERIC WARNING SCREENS:

      stop();

      slideIntervalNum = setInterval(showNextSlide, 1000);

       

      var timeOut:Number;

      btn_mode.onPress = function()

          {

          timeOut = setTimeout(delayedAction, 1000);

          btn_mode.onRelease = function()

              {

              AudibleBeep1 = new Sound(this);

              AudibleBeep1.attachSound(btnPressBeep);

              AudibleBeep1.start(0, 1);

             

              clearTimeout(timeOut);

              delete btn_mode.onRelease;

              gotoAndPlay("initialization_yes");

              }

             

              function delayedAction()

              {

              AudibleBeep1 = new Sound(this);

              AudibleBeep1.attachSound(btnPressBeep);

              AudibleBeep1.start(0, 1);

             

              delete btn_mode.onRelease;

              gotoAndStop(thisFrame);

              }

          }

       

      //please help!!! thank you!

        • 1. Re: Timeout / stop(); not functioning properly on timeline
          kglad Adobe Community Professional & MVP

          you should clear every interval before setting it to prevent run-away intervals that can't be controlled:

           

           

           

          //AT STARTUP:

          stop();

           

          var slideIntervalNum:Number;

          var timeOut:Number;

          var currentFrame:String;

          thisFrame="enter_warning_init";

           

          function showNextSlide()

              {

              clearInterval(slideIntervalNum);

              _root.play();

              }

           

          clearInterval(slideIntervalNum);

          slideIntervalNum = setInterval(showNextSlide, 100);

           

          //BUTTON Requiring >1 Press

          btn_mode.onPress = function()

              {

              timeOut = setTimeout(delayedAction, 1000);

              btn_mode.onRelease = function()

                  {

                  clearTimeout(timeOut);

                  delete btn_mode.onRelease;

                  gotoAndPlay("enter_warning_init");

                  }

              }

          //BASIC CODE IN GENERIC WARNING SCREENS:  <- this must be in a different scope than the above code or you have problems.

          stop();

          var slideIntervalNum:Number;

           

          clearInterval(slideIntervalNum);

          slideIntervalNum = setInterval(showNextSlide, 1000);

           

          var timeOut:Number;

          btn_mode.onPress = function()

              {

              timeOut = setTimeout(delayedAction, 1000);

              btn_mode.onRelease = function()

                  {

                  AudibleBeep1 = new Sound(this);

                  AudibleBeep1.attachSound(btnPressBeep);

                  AudibleBeep1.start(0, 1);

                 

                  clearTimeout(timeOut);

                  delete btn_mode.onRelease;

                  gotoAndPlay("initialization_yes");

                  }

                 

                  function delayedAction()

                  {

                  AudibleBeep1 = new Sound(this);

                  AudibleBeep1.attachSound(btnPressBeep);

                  AudibleBeep1.start(0, 1);

                 

                  delete btn_mode.onRelease;

                  gotoAndStop(thisFrame);

                  }

              }

           

          //please help!!! thank you!

          • 2. Re: Timeout / stop(); not functioning properly on timeline
            xcmuddman Level 1

            Thanks KGLAD. I missed you!!!