ContextMenu.builtInItems 337
Description
Constructor; creates a new ContextMenu object. You can optionally specify an identifier for an
event handler when you create the object. The specified function is called when the user invokes
the context menu, but before the menu is actually displayed. This is useful for customizing menu
contents based on application state or based on the type of object (movie clip, text field, or
button) that the user right-clicks or Control-clicks. (For an example of creating an event handler,
see
ContextMenu.onSelect.)
Example
The following example hides all the built-in objects in the Context menu. (However, the Settings
and 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 menu
item (using the
ContextMenu.customItems array) based on the value of a Boolean variable
named
showItem. If false, the custom menu item is disabled; otherwise, it’s enabled.
var showItem = false; // Change this to true to see its effect
my_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 also
Button.menu, ContextMenu.onSelect, ContextMenu.customItems,
ContextMenu.hideBuiltInItems(), MovieClip.menu, TextField.menu
ContextMenu.builtInItems
Availability
Flash Player 7.
Usage
my_cm.builtInItems
Description
Property; 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 corresponding
menu items from the specified ContextMenu object. These properties are enumerable and are set
to
true by default.