1 Reply Latest reply on Mar 30, 2010 7:44 PM by Ned Murphy

    Time out function when no mouse clicks or mouse holds detected

    xcmuddman

      Hi All,

       

      Is there anything that i can add/remove to/from the following code to make  it not timeout while the mouse button is being held down too?

       

      i have tried to modify Harry's code with the following:

       

       

       

      import mx.utils.Delegate;

       

      btn1.onPress = function(){
          clearTimeout();
          }

       

      btn2.onPress = function(){
              clearTimeout();
              }

       

      btn1.onMouseUp = function(){
          clearTimeout(nTimeoutId);
          setUserActivityTimeout()
          };
      btn2.onMouseUp = function(){
          clearTimeout(nTimeoutId);
          setUserActivityTimeout()
          };
      btn1.onMouseDown = function(){
          clearTimeout(nTimeoutId);
          setUserActivityTimeout()
          };
      btn2.onMouseDown = function(){
          clearTimeout(nTimeoutId);
          setUserActivityTimeout()
          };
      function setUserActivityTimeout():Void
      {
          clearTimeout(nTimeoutId)
          nTimeoutId = setTimeout(Delegate.create(this, onUserInactivity), nTimeTolerance);
      }

       

      function stopTimer():Void
      {
          clearTimeout(nTimeoutId)
      }
      function onUserInactivity():Void
      {
          delete_root.onMouseUp;
      gotoAndStop("exit_no");
      }

       

       

       

       

      Ned - im not skilled in programming enough to follow through with your advice:

      "Look into disabling the timer until a mouse up event occurs."

       

      something like:

       

      if

       

      MouseEvent.press == true

       

      then

       

          clearTimeout(nTimeoutId)

       


      ????\

       

       

       

       

      Pat

        • 1. Re: Time out function when no mouse clicks or mouse holds detected
          Ned Murphy Adobe Community Professional & MVP

          If you don't want the setTimeout to be operating while the mouse is down, do not call the setUserActivityTimeout() function in your mouse down code.

           

          Your mouse up code already has what I suggested.

           

          To become skilled in programming you need to be able to realize what tools you have and how to use them.  That won't come from people handing you solutions unfortunately... you've gotta lose hair, sleep, and your marbles to earn that skill.