AS3 close contextMenu
is it possible to close a contextMenu (or hide it) from ActionScript 3?
I need to run an eventlistener and once the right Mousebutton is pressed something happens.
myContextMenu.addEventListener(ContextMenuEvent.MENU_SELECT, menuSelectHandler);
function menuSelectHandler(e:ContextMenuEvent):void{
/**
* close the context menu and do something
*/
}
Either 开发者_运维百科do not even show the context menu or close it.
Any idea how I can do this?
I have tried:
dispatchEvent(new ContextMenuEvent(ContextMenuEvent.MENU_ITEM_SELECT));
But it's not launching my eventListener I placed on the first Menu item. Any idea how to dispatch the event that is launched, when an item in the ContextMenu is choosen?
You can't close, hide or disable the right click in Flash Player, as much, you can hide some of the options.
But there's a trick, you can use JS to capture the right click and simulate your own right click inside your Flash app using ExternalInterface.
You can see some examples of this here:
http://www.lordofduct.com/blog/?p=318
http://www.uza.lt/2007/08/19/solved-right-click-in-as3/
http://blog.another-d-mention.ro/programming/right-click-and-custom-context-menu-in-flash-flex/
The problem with this is the browser compatility, and also you need to change the wmode (which has more problems in some situations, you can search about it).
Here are some stats about compatibility:
http://code.google.com/p/custom-context-menu/wiki/BrowserSupport
Actually you can't really do anything about it. You can only reduce the size of the context menu to few entries, but something need to appear. The reason is that Flash doesn't really support the right-click button of your mouse, but only deliver the content for ContextMenu. Have you ever seen any Flash application that doesn't show the context menu after right-clicking on it?
精彩评论