[ Pobierz całość w formacie PDF ]
.(However, the Settingsand About items still appear, because they cannot be disabled.)var newMenu = new ContextMenu();newMenu.hideBuiltInItems();_root.menu = newMenu;In this example, the specified event handler, menuHandler, enables or disables a custom menuitem (using the ContextMenu.customItems array) based on the value of a Boolean variablenamed showItem.If false, the custom menu item is disabled; otherwise, it s enabled.var showItem = false; // Change this to true to see its effectmy_cm = new ContextMenu(menuHandler);my_cm.customItems.push(new ContextMenuItem("Hello", itemHandler));function menuHandler(obj, menuObj) {if (showItem == false) {menuObj.customItems[0].enabled = false;} else {menuObj.customItems[0].enabled = true;}}function itemHandler(obj, item) {}_root.menu = my_cm;See alsoButton.menu, ContextMenu.onSelect, ContextMenu.customItems,ContextMenu.hideBuiltInItems(), MovieClip.menu, TextField.menuContextMenu.builtInItemsAvailabilityFlash Player 7.Usagemy_cm.builtInItemsDescriptionProperty; an object that has the following Boolean properties: save, zoom, quality, play, loop,rewind, forward_back, and print.Setting these variables to false removes the correspondingmenu items from the specified ContextMenu object.These properties are enumerable and are setto true by default.ContextMenu.builtInItems 337 ExampleIn this example, the built-in Quality and Print menu items are disabled for the ContextMenuobject my_cm, which is attached to the root Timeline of the SWF file.var my_cm = new ContextMenu ();my_cm.builtInItems.quality=false;my_cm.builtInItems.print=false;_root.menu = my_cm;In the next example, a for.in loop enumerates through all names and values of the built-inmenu items of the ContextMenu object, my_cm.my_cm = new ContextMenu();for(eachProp in my_cm.builtInItems) {var propName = eachProp;var propValue = my_cm.builtInItems[propName];trace(propName + ": " + propValue;}ContextMenu.copy()AvailabilityFlash Player 7.Usagemy_cm.copy()ParametersNone.ReturnsA ContextMenu object.DescriptionMethod; creates a copy of the specified ContextMenu object.The copy inherits all the propertiesof the original menu object.ExampleThis example creates a copy of the ContextMenu object named my_cm whose built-in menu itemsare hidden, and adds a menu item with the text  Save..It then creates a copy of my_cm andassigns it to the variable clone_cm, which inherits all the properties of the original menu.my_cm = new ContextMenu();my_cm.hideBuiltInItems();my_cm.customItems.push(new ContextMenuItem("Save.", saveHandler);function saveHandler (obj, menuItem) {saveDocument(); // custom function (not shown)}clone_cm = my_cm.copy();338 Chapter 12: ActionScript Dictionary ContextMenu.customItemsAvailabilityFlash Player 7.Usagemy_cm.customItemsDescriptionProperty; an array of ContextMenuItem objects.Each object in the array represents a contextmenu item that you have defined.Use this property to add, remove, or modify these custommenu items.To add new menu items, you first create a new ContextMenuItem object, and then add it to themenu_mc.customItems array (using Array.push(), for example).For more information aboutcreating new menu items, see the ContextMenuItem class entry.ExampleThe following example creates a new custom menu item called menuItem_cm with a caption of Send e-mail and a callback handler named emailHandler (not shown).The new menu item isthen added to the ContextMenu object, my_cm, using the customItems array.Lastly, the newmenu is attached to a movie clip named email_mc.var my_cm = new ContextMenu();var menuItem_cm = new ContextMenuItem("Send e-mail", emailHandler);my_cm.customItems.push(menuItem_cm);email_mc.menu = my_cm;See alsoButton.menu, ContextMenu class, MovieClip.menu, TextField.menuContextMenu.hideBuiltInItems()AvailabilityFlash Player 7.Usagemy_cm.hideBuiltInItems()ParametersNone.ReturnsNothing.DescriptionMethod; hides all built-in menu items (except Settings) in the specified ContextMenu object.Ifthe Flash Debug Player is running, the Debugging menu item shows, although it is dimmed forSWF files that don t have remote debugging enabled.ContextMenu.hideBuiltInItems() 339 This method hides only menu items that appear in the standard context menu; it does not affectitems that appear in the edit or error menus.For more information about the different menutypes, see the ContextMenu class entry.This method works by setting all the Boolean members of my_cm.builtInItems to false.Youcan selectively make a built-in item visible by setting its corresponding member inmy_cm.builtInItems to true (as demonstrated in the following example).ExampleThe following example creates a new ContextMenu object named my_cm whose built-in menuitems are hidden, except for Print.The menu object is attached to the root Timeline.my_cm = new ContextMenu();my_cm.hideBuiltInItems();my_cm.builtInItems.print = true;_root.menu = my_cm;ContextMenu.onSelectAvailabilityFlash Player 7.Usagemy_cm [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • czarkowski.pev.pl
  •