With Flash Player 11.2, we now have access to mouse events for the right mouse button:
- MouseEvent.RIGHT_CLICK
- MouseEvent.RIGHT_MOUSE_DOWN
- MouseEvent.RIGHT_MOUSE_UP
However, when I try to use these to implement a right-mouse-button drag&drop, it seems that once the right mouse button is down, I no longer get MouseEvent.MOUSE_MOVE and the stage's MouseX and MouseY members stop updating until the button is released. This makes it effectively impossible to implement that drag&drop.
Use the code example in Flash Builder below to see what I mean:
- Launch it, move your mouse around and you'll see logs of your mouse position updating.
- Press and hold LMB, move your mouse around, you'll see more logs, great!
- Release LMB, press and hold LMB, move your mouse around, no logs, bad!
Is this a limitation of AS3? I can't seem to find any documentation about it.
Code Example:
package
{
import flash.display.Sprite;
import flash.events.MouseEvent;
public class TestFlash extends Sprite
{
public function TestFlash()
{
if(stage){
stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
stage.addEventListener(MouseEvent.MOUSE_DOWN, onLMBDown);
stage.addEventListener(MouseEvent.MOUSE_UP, onLMBUp);
stage.addEventListener(MouseEvent.RIGHT_MOUSE_DOWN, onRMBDown);
stage.addEventListener(MouseEvent.RIGHT_MOUSE_UP, onRMBUp);
}
}
private function onMouseMove(event:MouseEvent) : void
{
trace("Mouse Pos, from event: x = " + event.localX + " y = " + event.localY + " from stage: x = " + stage.mouseX + " y = " + stage.mouseY);
}
private function onRMBDown(event:MouseEvent) : void
{
trace("RMB down");
}
private function onRMBUp(event:MouseEvent) : void
{
trace("RMB up");
}
private function onLMBDown(event:MouseEvent) : void
{
trace("LMB down");
}
private function onLMBUp(event:MouseEvent) : void
{
trace("LMB up");
}
}
}