开发者

Catch Right-Click AS3

开发者 https://www.devze.com 2023-02-04 18:03 出处:网络
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 a开发者

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 a开发者_运维问答s 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.


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.


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


Without Javascript! Yes it works fine.

I tell you: If you are use Flex- or Flash-Builder than you need add rightClick from root application tag: example: <s:Applikation .... RightClick="appRightClick (event)"> Than you need to switch off contextmenu to null.

And you add bordercontainer or view than add rightClick with any rightClick-function than you need to add menu from mx.controls.Menu and menu1 needs to listen to rightClick to appRightClick (event)

Because it doesn't access from Flash Player Contextmenu.

I hope it because your flash applikation works for rightClick :)

0

精彩评论

暂无评论...
验证码 换一张
取 消