练习ContextMenuItem对象
<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="onCreationComplete()"><mx:Script><![CDATA[import flash.events.ContextMenuEvent;import mx.controls.Alert;private function onCreationComplete():void{var item_1:ContextMenuItem=new ContextMenuItem("完整系统的万维网应用程序开发知识体系",true,false);//插入一跳分割线,并禁止该菜单项var item_2:ContextMenuItem=new ContextMenuItem("《HTML开发网》",true);//插入一条分割线var item_3:ContextMenuItem=new ContextMenuItem("《CSS开发网》");var item_4:ContextMenuItem=new ContextMenuItem("《javascript》");var item_5:ContextMenuItem=new ContextMenuItem("《Flash开发网》");var myContextMenu:ContextMenu=new ContextMenu();myContextMenu.hideBuiltInItems();//隐藏指定的ContextMenu对象中的所有内建菜单项("设置"菜单和"关于Adobe Flash Player"菜单项除外).myContextMenu.customItems.push(item_1);myContextMenu.customItems.push(item_2);myContextMenu.customItems.push(item_3);myContextMenu.customItems.push(item_4);myContextMenu.customItems.push(item_5);myContextMenu.addEventListener("menuSelect",menuHandler);item_1.addEventListener("menuItemSelect",itemHandler);item_2.addEventListener("menuItemSelect",itemHandler);item_3.addEventListener("menuItemSelect",itemHandler);item_4.addEventListener("menuItemSelect",itemHandler);item_5.addEventListener("menuItemSelect",itemHandler);}private function menuHandler(evt:ContextMenuEvent):void{Alert.show("右键菜单弹出");}private function itemHandler(evt:ContextMenuEvent):void{Alert.show(evt.target.caption);}]]></mx:Script></mx:Application>
?