ContextMenu类
ContextMenuBuiltInItems类
//定义CM对象,赋值给可视元件.
//而后的代码中,会对cm的属性进行修改。达到自定义的效果
//那么就会分别对●内置菜单 ●用户菜单 进行修改
mc.contextMenu=cm;
//当然你也可以赋值给舞台。如下语句
//contextMenu=cm;
/////////////编辑内置菜单////////////////////////////////////////
cm.hideBuiltInItems();
/*//也可以用下面方法,选择性隐藏内置菜单
var cmb:ContextMenuBuiltInItems=new ContextMenuBuiltInItems();
cmb.print=false;
cmb.quality=false;
cmb.zoom=false;
cmb.loop=false;
cm.builtInItems=cmb; // builtInItems属性是一个ContextMenuBuiltInItems值,
*/
////////////////////////////////////////////////////////////////////
////////////编辑用户菜单////////////////////////////////////////
var cm1:ContextMenuItem=new ContextMenuItem("菜单1",false,true,true)
var cm2:ContextMenuItem=new ContextMenuItem("菜单2",false,true,true)
var cm3:ContextMenuItem=new ContextMenuItem("菜单3",false,false,true)
cm.customItems.push(cm1);
cm.customItems.push(cm2);
cm.customItems.push(cm3);
////////////注意自定义菜单是可以在运行中动态修改的。看个人发挥了////////////
//////////////////////////侦听事件函数////////////////////////
//注意侦听的对象是ContextMenuItem,
//在下面依次对cm1,cm2,cm3,三个ContextMenuItem对象添加侦听。
cm1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,clickMenu)
cm2.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,clickMenu)
cm3.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,clickMenu)
function clickMenu(e:ContextMenuEvent){
}