You use the ContextMenuItem object to create custom menu items to display in the Flash Player context menu. Each ContextMenuItem object has a caption (text) that's displayed in the context menu and a callback handler (a function) that's invoked when the menu item is selected.
You can use the properties of the ContextMenuItem object to enable or disable specific menu items, make menu items visible or invisible, or change the caption or callback handler associated with a menu item.
You must add ContextMenuItem objects to the ContextMenu.customItems
array to make them appear in the Flash Player context menu.
Method | Description |
---|---|
ContextMenuItem.copy() |
Returns a copy of the specified ContextMenuItem object. |
Property | Description |
---|---|
ContextMenuItem.caption |
Specifies the text displayed in the menu item. |
ContextMenuItem.enabled |
Specifies whether the menu item is enabled or disabled. |
ContextMenuItem.separatorBefore |
Specifies whether a separator bar should appear before (above) the menu item. |
ContextMenuItem.visible |
Specifies whether the menu item is visible or not. |
Event handler | Description |
---|---|
ContextMenuItem.callback |
User-defined function that is called when the menu item is selected. > |
Flash Player 7.
new ContextMenuItem (caption
,callback
, [separatorBefore
,] [enabled
,] [visible]
);
caption
A string that specifies the text associated with the menu item.
callback
A function, defined by you, that's called when the menu item is selected.
separatorBefore
A Boolean value that indicates whether a separator bar should appear above the menu item in the context menu. This parameter is optional; its default value is false
.
enabled
A Boolean value that indicates whether the menu item is enabled or disabled in the context menu. This parameter is optional; its default value is true
.
visible
A Boolean value that indicates whether the menu item is visible or invisible. This parameter is optional; its default value is true
.
An instance of the ContextMenuItem object.
Constructor; creates a new ContextMenuItem object that can be added to the ContextMenu.customItems
array.
This example adds Start and Stop menu items, separated by a bar, to the ContextMenu object menu_cm
. The stopHandler
function is called when Stop is selected from the context menu; startHandler
is called when Start is selected. The custom menu object is applied to the root Timeline.
menu_cm = new ContextMenu(); menu_cm.customItems.push(new ContextMenuItem("Start", startHandler)); menu_cm.customItems.push(new ContextMenuItem("Stop", stopHandler, true)); function stopHandler(obj, item) { trace("Stopping..."); } function startHandler(obj, item) { trace("Starting..."); } _root.menu = menu_cm;