Skip to main content
Perfect_Nemus
Known Participant
February 7, 2010
Answered

I need the opposite of a Mouse_Move event

  • February 7, 2010
  • 1 reply
  • 929 views

Hi folks,

i'm back from months fo hard working

So let me explain my actual problem: I need to dispatch an event object when user stops moving mouse cursor. In poor words, i need the exatly opposite of a Mouse_Move event. Is there any solution or I need to create a event with EventDispatcher class?

This topic has been closed for replies.
Correct answer kglad

now all is right. I'm trying


if you have a document class you can add the following:

package{
   
    import flash.events.Event;
    import flash.events.TimerEvent;
    import flash.events.MouseEvent;
    import flash.display.MovieClip;
    import flash.utils.Timer;
   
    public class Main extends MovieClip{
       
        var idleTime:uint = 1000;  // assign the value you want
        var idleEvent:Event = new Event("IDLE_EVENT");
        var timer:Timer = new Timer(idleTime,0);
       
        function Main(){
            timer.addEventListener(TimerEvent.TIMER,dispatchEventF);
            timer.start();
            stage.addEventListener(MouseEvent.MOUSE_MOVE,resetF);
        }
       
        private function dispatchEventF(e:TimerEvent){
            dispatchEvent(idleEvent);
        }
        private function resetF(e:MouseEvent){
            timer.reset();
            timer.start();
        }
       
    }
}

and you can add a listener to your main timeline or that class for the "IDLE_EVENT"

1 reply

kglad
Community Expert
Community Expert
February 7, 2010

you can create your own event but, there will need to be some sort of time parameter to determine when this event should be dispatched.  and what class will dispatch it, the stage?

Perfect_Nemus
Known Participant
February 7, 2010

Yes, it could be the stage class

But i didn't understand your idea of a timer

February 7, 2010

what kglad is saying is that on mouse move you will reset a Global timer.

You can use the Timer class or extend it and make one yourself.  give it a duration and timer.start()  each time the mouse move happens reset the timer.

if the timer actually makes it to its dealine.. fire your event