- standard menu items like "About Flash Player" cannot be removed
- you can have 15 menu items at max
- you can not have sub menus
- several key words are reserved, like "copy" und "cut" and can not be used
Some clever developers have found a way to catch the right click event in the HTML container using Javascript and to forward the event to the Flash Player via the External interface (see here for the project site).
A right click in the following sample application opens a simple Flex menu which does not have the limitations descriped above.
To view this page ensure that Adobe Flash Player version 10.0.0 or greater is installed.
Now let's have a look at the code:
import mx.controls.Menu;
import mx.events.FlexMouseEvent;
import mx.managers.PopUpManager;
private var menu:Menu;
private function creationCompleteHandler( event:Event ):void
{
ExternalInterface.addCallback( "rightClick", rightClickHandler );
}
private function rightClickHandler():void
{
showMenu();
}
public function showMenu():void
{
hideMenu();
menu = Menu.createMenu( this, menuItems );
menu.show( stage.mouseX, stage.mouseY );
}
public function hideMenu():void
{
if( menu != null )
{
PopUpManager.removePopUp( menu );
}
}In the creationCompleteHandler a callback is added to external interface which gets called every time the right mouse button is pressed.The callback rightClickHandler simply opens the Flex menu.
Check out the following links for more information on the topic:
No comments:
Post a Comment