import flash.ui.ContextMenu; import flash.net.URLRequest; import flash.net.navigateToURL; var copyright:String="版权声明:"; var context:String="未经允许不得以任何方式复制.盗用.链接."; var link:String="http://www.baidu.com"; var _contextMenu:ContextMenu; var copyright_CM:ContextMenuItem; var context_CM:ContextMenuItem; var link_CM:ContextMenuItem; _contextMenu=new ContextMenu(); _contextMenu.hideBuiltInItems(); copyright_CM=new ContextMenuItem(copyright); context_CM=new ContextMenuItem(context); //context_CM.separatorBefore = true;//在copyright上加入分隔线 link_CM=new ContextMenuItem(link); link_CM.separatorBefore = true link_CM.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, openLink); _contextMenu.customItems.push(copyright_CM,context_CM,link_CM); function openLink(evt:ContextMenuEvent):void{ navigateToURL(new URLRequest(link)); } this.contextMenu = _contextMenu;//将当前菜单drMenu设置为主菜单