当前位置:软件学习 > Flash >>

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

 代码如下 复制代码

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

补充:flash教程,As3.0
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,