1
votes

I have a rollOver event on a pop-up button in flex. I want that the menu is opened on rollover. But if the user accidentally goes with the mouse over the component the menu should not be displayed. So on rollOver I want to start a timer (wait for half second) and than check if the user is still on the pop-up button (rollOut was not fired).

My example code so far:

             private function rollOverMenu(event:Event){
            rollOutNow = false;
            var shortDelay:Timer = new Timer(3000);
            shortDelay.addEventListener(TimerEvent.TIMER_COMPLETE, timerCompleteEvent);
            shortDelay.start();
         }

        private function timerCompleteEvent(event:Timer){
            Alert.show("time is up");
            if (!rollOutNow){
                /*open the menu*/
            }
         }

The Alert "time is up" is never shown, any ideas why my timer event does not work?

2

2 Answers

1
votes

Yes, but by only providing the delay, and not the repeat count the timer goes on forever, only dispatching the TimerEvent.TIMER event.

Either listen for the TimerEvent.TIMER event instead, or make the constructor take the arguments like this: new Timer(3000,1) where 1 is the repeat count.

1
votes

u can also use something like this..

on rollover method(): {
// this sleeps for 3000 milliseconds and then call the method functionName.so     
  implement ur functionality inside "functionName"

setTimeout(3000,functionName);
}