views:

12

answers:

1

I have a slider with arrows on the end to operate/advance it. If you hover over an arrow the slider slides. When you roll off/hover off the arrow the slider stops. The problem is that if you hover off to quickly it still thinks the cursor is over the arrow and it continues to slide. Is there any way to address this?

+1  A: 

The solution depends on whether you are using ActionScript 2 or ActionScript 3. The problem is that Flash performs actions on a frame by frame basis, and your cursor is leaving the stage before the next frame executes.

If you're using AS3, all you need is to listen for the Event.MOUSE_LEAVE event, which will be triggered when the mouse exits the stage. You can then stop the sliding in the event handler there.

If you're using AS2, there is no analogous event to listen to, and the best solutions tend to involve running an enterframe to keep track of the position/direction/speed of the cursor. They then determine that if mouse move events have stopped and the last position/direction/speed suggest an exit from the stage, that they can assume the mouse has left and you could then stop the sliding.

Tegeril