一聚教程网:一个值得你收藏的教程网站

热门教程

as3增加自定义右键菜单实现程序

时间:2022-06-28 22:15:11 编辑:袖梨 来源:一聚教程网

 代码如下 复制代码

var myContextMenu:ContextMenu = new ContextMenu();
var mAuthor:ContextMenuItem = new ContextMenuItem("关于自己");
myContextMenu.customItems.push(mAuthor);
var mPage:ContextMenuItem = new ContextMenuItem("我的主页",true);
myContextMenu.hideBuiltInItems();
myContextMenu.customItems.push(mPage);
this.contextMenu = myContextMenu;

mAuthor.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, itemSelectHandler);
mPage.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, itemSelectHandlerII);
function itemSelectHandler(e:ContextMenuEvent):void {
  trace("关于自己对应的函数");
}
function itemSelectHandlerII(e:ContextMenuEvent):void {
  trace("我的主页对应的函数");
}

热门栏目