Flex 오른쪽 단추 메뉴 옵션 설정

2330 단어 UIxmlFlexFlash
<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute”
creationComplete=”init()” >
<mx:Script>
   <![CDATA[
      

import flash.display.Sprite;
     import flash.ui.ContextMenu;
     import flash.ui.ContextMenuItem;
     import flash.events.ContextMenuEvent;
     //    ,      
     private var menu1:ContextMenuItem;
     private var menu2:ContextMenuItem;
     private var menu3:ContextMenuItem;
     //      
     public function init():void{
     textSelect.text = "RightClick is Default";
     menu1= new ContextMenuItem("Draw Red");
     menu2 = new ContextMenuItem("Draw Yellow");
     menu3 = new ContextMenuItem("Default");
     //           
     menu1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,menudraw);
     menu2.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,menudraw);
     menu3.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,menudraw);
    
     //               ,  ContextMenu 
     var MyMenu:ContextMenu = new ContextMenu();
     MyMenu.hideBuiltInItems();
     MyMenu.customItems.push(menu1);
     MyMenu.customItems.push(menu2);
     MyMenu.customItems.push(menu3);
//            ,          ,            ,   this         
//          .
     this.contextMenu = MyMenu;
     }
     //          ,    
     private function menudraw(e:ContextMenuEvent):void {
        switch (e.target) {
         case menu1 :
           textSelect.text = "RightClick IS READ";
//            pan.draw(0xff0000);
           break;
         case menu2 :
           textSelect.text = "RightClick IS Yellow";
//            pan.draw(0xffcc00);
           break;
         case menu3 :
           textSelect.text = "RightClick is Default";
//            pan.draw(0x0099cc);
           break;
       }
     }
         
   ]]>
</mx:Script>
<mx:Label x=”97″ y=”60″ id=”textSelect” text=”Test Right-Click”/>
</mx:Application>

내력 을 잊어버리다

좋은 웹페이지 즐겨찾기