3
votes

I'm listening for MOUSE_MOVE events.

They are sent and received just fine unless the middle mouse button is held down. I don't get any more MOUSE_MOVE events until the middle button is released.

Is this an issue with Flash, or something to do with my specific mouse/computer configuration (bluetooth Mighty Mouse on Lion)?

Are there any known workarounds?


Here is a sample project to demonstrate the problem.
Left click and drag traces mouse move events, but middle click only shows middle mouse down and middle mouse up.

import flash.events.MouseEvent;

this.stage.addEventListener(MouseEvent.MIDDLE_MOUSE_DOWN, onMiddleMouseDown);
this.stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);

function onMiddleMouseDown(e:MouseEvent):void {
trace("middle down");

this.stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
this.stage.addEventListener(MouseEvent.MIDDLE_MOUSE_UP, onMiddleMouseUp);
}

function onMouseMove(e:MouseEvent):void {
trace("mouse move");
}

function onMiddleMouseUp(e:MouseEvent):void {
trace("middle up");

this.stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
this.stage.removeEventListener(MouseEvent.MIDDLE_MOUSE_UP, onMiddleMouseUp);
}

function onMouseDown(e:MouseEvent):void {
trace("down");

this.stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
this.stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
}

function onMouseUp(e:MouseEvent):void {
trace("up");

this.stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
this.stage.removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
}

UPDATE:
It appears that the mouse position (mouseX and mouseY properties) are not being updated when the middle button is held down. I'd still like to know why, or if there is a workaround for this.

3
Looks like it is an issue with your setup. I just copy-pasted your code to test and MOUSE_MOVE fires correctly and mouseX and mouseY update properly. Pretty odd.Pixel Elephant
Oh cool, good to know. Thanks. I'm guessing it's a Mac/Lion thing. I've tried a few different mice and fiddled with my mouse settings and nothing seems to make a difference.Cadin

3 Answers

0
votes

Just a guess, but the middle mouse button is usually set in most drivers to enable scrolling. Probably means that instead of mouse move messages the window gets some kind of scroll messages while the button is pressed.

0
votes

Do you absolutely need the MOUSE_MOVE event? Most times an ENTER_FRAME event can replace it pretty well.

addEventListener(Event.ENTER_FRAME, eFrame);
private function eFrame(event:Event):void
{
   trace(mouseX,mouseY);
}
0
votes

Looks like this was a bug in the Flash Player for Mac.
Adobe has fixed it:
https://bugbase.adobe.com/index.cfm?event=bug&id=3674152