2、ontext,oftheoperatingsystemorapplication(source:enu; import flash.ui.ContextMenuItem; import flash.events.ContextMenuEvent; public class context extends Sprite { // this is the circle you see on the stage public var the_sphere:sphere=neenus public var place_randomly_menu:Contex
3、tMenu=neenu:ContextMenu=neenu items public var place_randomly_item:ContextMenuItem=ne("Place randomly"); public var reset_item:ContextMenuItem=ne("Reset"); public function context() { // placing the circle on the stage addChild(the_sphere); // calling the function to plac
4、e the sphere in the middle of the stage // I am passing a null value because it's the same function I am using // in the listener, and functions in listeners require a parameter reset_sphere(null); // adding to the context menu item a listener to execute "place_sphere" fun
5、ction place_randomly_item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,place_sphere); // hiding default items in the context menu place_randomly_menu.hideBuiltInItems(); // pusing (in this case placing) the menu item in the context menu place_randomly_menu.customIt
6、ems.push(place_randomly_item); // assigning the context menu to the circle the_sphere.contextMenu=(place_randomly_menu) // repeating the same thing enu, the stage one reset_item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,reset_sphere); reset_menu.hideBuiltInItems
7、(); reset_menu.customItems.push(reset_item);12下一页[感谢阅读这篇文章,..,]this.contextMenu=reset_menu; } public function place_sphere(event:ContextMenuEvent):void { the_sphere.x=Math.random()*400+50; the_sphere.y=Math.random()*300+50; } public function reset_sphere(event:ContextMen