自定义Flash右键上下文选项——自定义类BlockRightClick
package { import flash.ui.ContextMenu; import flash.ui.ContextMenuItem; import flash.events.ContextMenuEvent; import flash.net.URLRequest; import flash.net.navigateToURL; public class BlockRightClick { private static var _contextMenu:ContextMenu; private static var _copyrightTitle:String = "版权声明:"; private static var _copyrightContext:String = "未经允许不得以任何方式复制.盗用.链接.."; private static var _linkTitle:String = "链接网址:"; private static var _linkUrl:String = "http://www.baidu.com"; private static var copyrightTitle_item:ContextMenuItem; private static var copyrightContext_item:ContextMenuItem; private static var link_item:ContextMenuItem; public function BlockRightClick():void { init(); } public static function setRigthButton():ContextMenu { _contextMenu=new ContextMenu(); _contextMenu.hideBuiltInItems(); copyrightTitle_item = new ContextMenuItem(_copyrightTitle); copyrightContext_item = new ContextMenuItem(_copyrightContext); link_item = new ContextMenuItem(_linkTitle+_linkUrl); link_item.separatorBefore = true; link_item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, openLink,false,0,true); _contextMenu.customItems.push(copyrightTitle_item,copyrightContext_item,link_item); return _contextMenu; } private static function openLink(evt:ContextMenuEvent):void { navigateToURL(new URLRequest(_linkUrl)); } //------------------------------------------------------------------------------@get、set public static function get copyrightTitle():String{ return _copyrightTitle; } public static function set copyrightTitle(value_:String):void{ _copyrightTitle=value_; } public static function get copyrightContext():String{ return _copyrightContext; } public static function set copyrightContext(value_:String):void{ _copyrightContext=value_; } public static function get linkTitle():String{ return _linkTitle; } public static function set linkTitle(value_:String):void{ _linkTitle=value_; } public static function get linkUrl():String{ return _linkUrl; } public static function set linkUrl(value_:String):void{ _linkUrl=value_; } } }