右键菜单

<script type="text/javascript" src="rightClick.js"></script>

 

 

 

 

 

ExternalInterface.addCallback("rightClick",onMouseRightButtonClicked);

 

 

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
 applicationComplete="onAppCreated()" width="495" height="342" viewSourceURL="srcview/index.html">
 
 
  <!-- Define the menu data. This is an official example from livedoc -->
    <mx:XML format="e4x" id="myMenuData">
        <root>
            <menuitem label="MenuItem A">
                <menuitem label="SubMenuItem A-1" enabled="false"/>
                <menuitem label="SubMenuItem A-2"/>
            </menuitem>
            <menuitem label="MenuItem B" type="check" toggled="true"/>
            <menuitem label="MenuItem C" type="check" toggled="false"/>
            <menuitem type="separator"/>    
            <menuitem label="MenuItem D">
                <menuitem label="SubMenuItem D-1" type="radio" groupName="one" />
                <menuitem label="SubMenuItem D-2" type="radio" groupName="one" toggled="true"/>
                <menuitem label="SubMenuItem D-3" type="radio" groupName="one" />
            </menuitem>
            <menuitem type="separator"/> 
            <menuitem label="Custom View Source"/>
        </root>
    </mx:XML>

 
 
 <mx:Script>
  <![CDATA[
   import flash.net.navigateToURL;
   import mx.events.MenuEvent;
   import mx.controls.Menu;
   import mx.controls.Alert;
   
   //my Menu Instance
   private var myMenu:Menu;
   
   //In the application created event, we initialize a callback for
   //ExternalInterface using a same name "rightClick" used on the javascript code.
   private function onAppCreated():void{
    ExternalInterface.addCallback("rightClick",onMouseRightButtonClicked);
   }
   
   //the magic method, called by javascript through ExternalInterface.
   private function onMouseRightButtonClicked():void{
    //if exists an before Menu, simpply hide it.
    if (myMenu != null) myMenu.hide();
    
    //creating a Menu
    myMenu = Menu.createMenu(null, myMenuData,false);
                myMenu.labelField="@label";
               
                //add a eventListener
                myMenu.addEventListener(MenuEvent.ITEM_CLICK,myMenuItemClicked);
               
                //show the Menu where the mouse pointer is located.
                myMenu.show(stage.mouseX, stage.mouseY);
                
            
                                                
   }
   
   //This method is invoked when a menu item was clicked.
   private function myMenuItemClicked(e:MenuEvent):void {
    
    //if "customViewSource" alias was clicked...
    if (e.label=="Custom View Source") {
     //... then, show the view source page.
     navigateToURL(new URLRequest("srcview/index.html"));
    }
   }
   
  ]]>
 </mx:Script>
 <mx:Label x="18.5" y="10" text="Clique com o botão direito do Mouse sobre a área da aplicação" fontWeight="bold" fontSize="13"/>
 <mx:Label x="49.5" y="310" text="Click the right mouse button over the application area" fontWeight="bold" fontSize="13"/>
 
</mx:Application>

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值