Catch Right-Click AS3

11,395

Solution 1

There are only two ways to capture a right click event:

  1. For a web browser application: Use JavaScript. You can't do it directly in Flash, because you can't disable the context menu.

  2. For a desktop application: Deploy as an AIR application. AIR has a RIGHT_CLICK MouseEvent built in.

There's no step three. :(

P.S: That is, if menuSelect really doesn't work for you - the documentation says it is triggered before the menu is opened.

Solution 2

Just as weltraumpirat reported, the only way to capture the Right Click event is if you are building your application to be deployed as an AIR application if you want to keep it all native to the Flash Platform Architecture; otherwise you will need to use some other language in conjunction with Flash to capture the event (i.e. JavaScript).

FYI, here is the API reference for the MouseEvent Class that contains information about the RightClick event: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/MouseEvent.html

Share:
11,395
Jon Sandness
Author by

Jon Sandness

Updated on June 04, 2022

Comments

  • Jon Sandness
    Jon Sandness almost 2 years

    Is it possible to catch a right-click inside of flash (AS3)?

    No JQuery/JavaScript.

    I need to pause gameplay when a right-click is caught, so I don't so much want to disable the context-menu as I do just want to tell that a right-click has happened. Is there an EventListener I can add? Any other ideas?

    UPDATE:
    I need the event to be triggered as they are actually right clicking, not just after the context-menu has disappeared.