Flex 添加右件菜单

<? xml version="1.0" encoding="utf-8" ?>
< mx:Application  xmlns:mx ="http://www.adobe.com/2006/mxml"  layout ="absolute"  creationComplete ="InitApp();" >
    
< mx:Script >
        
<![CDATA[
            import mx.events.MenuEvent;
            import mx.controls.Alert;
            
            private function InitApp():void{
                var myContextMenu : ContextMenu = new ContextMenu();
                var item3 : ContextMenuItem = new ContextMenuItem("关于Flex(&A)");
                item3.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,item3Click);
                myContextMenu.customItems.push(item3);
                myContextMenu.hideBuiltInItems();
                this.contextMenu = myContextMenu; 
            }
            
            private function item3Click(event:ContextMenuEvent):void{
                Alert.show('Adobe Flex2.0');
            }
        
]]>
    
</ mx:Script >
</ mx:Application >

你可能感兴趣的:(Flex)