屏蔽Flash右键菜单

江枫思渺然 提交于 2019-11-28 00:35:05
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设置为主菜单

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!