自定义FLASH右键菜单(as3.0)

Posted on 2009-12-16 01:28  萧木柯  阅读(1841)  评论(0编辑  收藏  举报

ContextMenuItem(caption:String, separatorBefore:Boolean = false, enabled:Boolean = true, visible:Boolean = true)

caption:指定上下文菜单中显示的菜单项标题(文本)
separatorBefore:指示指定的菜单项上方是否显示分隔条
enabled:指示指定的菜单项处于启用状态还是禁用状态
visible:指示在显示 Flash Player 上下文菜单时指定菜单项是否可见

  1. var myContextMenu:ContextMenu = new ContextMenu();
  2.  
  3. var item:ContextMenuItem = new ContextMenuItem("Lemtree");
  4. var item1:ContextMenuItem = new ContextMenuItem("我已经Unabled",true,false,true);
  5.  
  6. myContextMenu.customItems.push(item,item1);
  7. myContextMenu.hideBuiltInItems();
  8. this.contextMenu = myContextMenu;
  9.  
  10. item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT ,mouseClick);
  11. function mouseClick(event:ContextMenuEvent) {
  12. var txtField:TextField=new TextField();
  13. txtField.width=400;
  14. txtField.text="你点击了右键子菜单:Lemtree";
  15. addChild(txtField);
  16.  
  17. var url:String="http://www.cnblogs.com/lemtree/";
  18. var urlrequest:URLRequest=new URLRequest(url);
  19. navigateToURL(urlrequest,"_blank");
  20. }