Dec 11 2007

Custom cursor “bug” in ActionScript3

If you ever want to use a custom mouse cursor in AS3 (for say dragging) with rollover/rollout events toggling it (so it will only change the cursor for certain movie-clips), bear this in mind:
When the user moves the mouse to the right with a certain (slowish) speed, the (original) hidden mouse cursor will go over the custom cursor, so it will fire the rollout event. Then when Flash updates the custom cursor position, the original mouse cursor won`t be over the custom one anymore, so it fires the rollout event, thus the cursor blinks quite noticeably. And no, the event.updateAfterEvent() won`t help either.

The workaround for this is to add the MouseEvent.MOUSE_MOVE listener to the stage and watch the event.target in the handler function and toggle the custom cursor using that, so you can specify that Flash shouldn`t do the toggling (= keep the custom cursor on) when the mouse goes over it.

So it isn`t necessarily a Flash Player bug, because this behavior makes sense (the mouse updates much more frequently than the .swf), but well annoying to figure out anyway.