With Flash Player 11.2, we now have access to mouse events for the right mouse button:
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:
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");
}
}
}
Judging by the problem you are describing, I think you need to add the enter frame function, otherwise the trigger will only activate on the frame that the mouse is clicked and when its released
addEventListener(Event.ENTER_FRAME, dragdrop)
function dragdrop(event:Event):void {
"add dragging event here"
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.