Right-click flash acts differently than left-click

I just updated flash player 11.2, which allows you to listen to MouseEvent.RIGHT_MOUSE_UP and MouseEvent.RIGHT_MOUSE_DOWN.

I had a problem when these events do not act in the same way as their MOUSE_UP / MOUSE_DOWN. In particular, the MOUSE_UP event is fired regardless of where the mouse is located. This allows you to drag outside the flash memory window and still have a full cycle of going down → up whenever a user clicks on a flash player.

However, this is not like RIGHT_MOUSE_UP / DOWN. When I right-click inside the player and go beyond the player, I do not receive the RIGHT_MOUSE_UP event, which means that you can receive several RIGHT_MOUSE_DOWN events without receiving the UP event.

Is there a known workaround for this, or is there an option I have to install?

Edit:

Here is a sample code:

stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp); stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown); stage.addeventListener(MouseEvent.RIGHT_MOUSE_UP, onRightMouseUp); stage.addeventListener(MouseEvent.RIGHT_MOUSE_DOWN, onRightMouseDown); //... //all callback function follow a similar format as : private function onMouseUp(e : MouseEvent) : void { leftClick_ = false;//signaling that leftClick is not pressed } 
+6
source share
1 answer

you can listen when the mouse leaves the scene, which can act as a proxy for the RIGHT_CLICK_UP event.

 package { //Imports import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.Event; import flash.events.MouseEvent; //Class [SWF(width="640", height="480", frameRate="60", backgroundColor="0x555555")] public class RightClickTest extends Sprite { //Constructor public function RightClickTest() { stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; addEventListener(Event.ADDED_TO_STAGE, init); } //Initialize private function init(event:Event):void { removeEventListener(Event.ADDED_TO_STAGE, init); stage.addEventListener(MouseEvent.RIGHT_MOUSE_DOWN, mouseRightClickEventHandler); stage.addEventListener(MouseEvent.RIGHT_MOUSE_UP, mouseRightClickEventHandler); stage.addEventListener(Event.MOUSE_LEAVE, mouseLeaveEventHandler); } //Mouse Right Click Event Handler private function mouseRightClickEventHandler(event:MouseEvent):void { switch (event.type) { case MouseEvent.RIGHT_MOUSE_DOWN: trace("Right Mouse Down"); break; case MouseEvent.RIGHT_MOUSE_UP: trace("Right Mouse Up"); } } //Mouse Leave Event Handler private function mouseLeaveEventHandler(event:Event):void { trace("Mouse Leave"); } } } 

however, if you try to prevent the user from displaying several context menus of the context menu (or something similar), you can implement a simple code check to first hide the visible context menu of the context menu before displaying a new one.

+2
source

Source: https://habr.com/ru/post/914450/


All Articles