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

作者:袖梨 2022-06-28
 代码如下 复制代码

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("我的主页对应的函数");
}

相关文章

精彩推荐