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

flash As2和As3的右键菜单实例代码

As3:右键菜单

 代码如下 复制代码

var myContextMenu:ContextMenu = new ContextMenu();
myContextMenu.hideBuiltInItems();
//声明菜单新项
var item:ContextMenuItem = new ContextMenuItem("@author amyflash");
//添加到菜单显示项目数组
myContextMenu.customItems.push (item);
root.contextMenu = myContextMenu;

//点击按钮引发该事件
item.addEventListener (ContextMenuEvent.MENU_ITEM_SELECT ,mouseRelease);
function mouseRelease (event:ContextMenuEvent):void
{
  navigateToURL(new URLRequest("http://www.hzhuti.com/"));
}

As2:右键菜单

 代码如下 复制代码

var _amyflash = new ContextMenu();
//删除原始菜单状态!
_amyflash .hideBuiltInItems();
//自定义菜单项目!
_amyflash .customItems.push(new ContextMenuItem("copyright:amyflash", home));
//菜单子程序执行目标...
function home() {
 getURL("http://www.hzhuti.com//", "_blank");
}
_root.menu = _amyflash;

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