Archive for December, 2010

AS3 MOUSE_LEAVE no longer reliable

Wednesday, December 8th, 2010

Looks like certain browsers have updated mouse events so that MOUSE_MOVE works outside of the bounds of an swf on a page. This is really nice, but other mouse events do not seem to function properly. MOUSE_UP for example does not seem to get called in safari, and only gets called in chrome after an additional movement of the mouse. This becomes a kind of sticky situation for something like a scrollbar or object that you are using MOUSE_DOWN to gain focus and then looking at the stage to stop the mouse updates based on MOUSE_UP. The solution used to be to resign focus on MOUSE_LEAVE, but this does not appear to be firing. The only 2 things I could think of to do in these situations were to use javascript mouse events (which may not be a possibility based on the project) or 2 to force resignation of the mouse when leaving the stage.

In the mouse move handler I put:
if(mouseX > stage.stageWidth || mouseX < 0 || mouseY > stage.stageHeight || mouseY < 0){
// stop mouse move action

It does work, but it seems like a crappy approach. I will need to look and see if there's any documentation on this *feature* to see if there's another alternate approach to get a global mouse up event when the mouse is outside of the swf.