| Package | flash.ui |
| Class | public final class ContextMenuItem |
| Inheritance | ContextMenuItem EventDispatcher Object |
customItems array of a
ContextMenu object.
With the properties of the ContextMenuItem class you can enable or disable specific menu items, or make items visible or invisible.
You write an event handler for themenuItemSelect event
to add functionality to the menu item when the user selects it.
Custom menu items appear at the top of the context menu, above any built-in items. A separator bar always divides custom menu items from built-in items.
Restrictions:
Save Zoom In Zoom Out 100% Show All Quality Play Loop Rewind Forward Back Movie not loaded About Print Show Redraw Regions Debugger Undo Cut Copy Paste Delete Select All Open Open in new window Copy link
Adobe Macromedia Flash Player Settings
Note: When the player is running on a non-English system, the caption strings are compared to both the English list and the localized equivalents.
View the examples. See also| ContextMenu class, ContextMenuBuiltInItems class |
| Property | Defined by | ||
|---|---|---|---|
| caption : String
Specifies the menu item caption (text) displayed in the context menu.
| ContextMenuItem | ||
![]() | constructor : Object
A reference to the class object or constructor function for a given object instance.
| Object | |
| enabled : Boolean
Indicates whether the specified menu item is enabled or disabled.
| ContextMenuItem | ||
![]() | prototype : Object
[static]
A reference to the prototype object of a class or function object.
| Object | |
| separatorBefore : Boolean
Indicates whether a separator bar should appear above the specified menu item.
| ContextMenuItem | ||
| visible : Boolean
Indicates whether the specified menu item is visible when the Flash Player
context menu is displayed.
| ContextMenuItem | ||
| Event | Summary | Defined by | ||
|---|---|---|---|---|
Flash Player dispatches the menuItemSelect event when a user selects an item from a context menu. | ContextMenuItem | |||
| Function | Defined by | ||
|---|---|---|---|
|
ContextMenuItem(caption:String, separatorBefore:Boolean = false, enabled:Boolean = true, visible:Boolean = true)
Creates a new ContextMenuItem object that can be added to the
ContextMenu.customItems
array. | ContextMenuItem | ||
![]() |
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener
receives notification of an event.
| EventDispatcher | |
|
Creates and returns a copy of the specified ContextMenuItem object.
| ContextMenuItem | ||
![]() |
Dispatches an event into the event flow.
| EventDispatcher | |
![]() |
Checks whether the EventDispatcher object has any listeners registered for a specific type
of event.
| EventDispatcher | |
![]() |
Indicates whether an object has a specified property defined.
| Object | |
![]() |
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter.
| Object | |
![]() |
Indicates whether the specified property exists and is enumerable.
| Object | |
![]() |
Removes a listener from the EventDispatcher object.
| EventDispatcher | |
![]() |
Sets the availability of a dynamic property for loop operations.
| Object | |
![]() |
Returns the string representation of the specified object.
| Object | |
![]() |
Returns the primitive value of the specified object.
| Object | |
![]() |
Checks whether an event listener is registered with this EventDispatcher object or any of
its ancestors for the specified event type.
| EventDispatcher | |
caption:String [read-write]caption value restrictions.
public function get caption():String
public function set caption(value:String):void
enabled:Boolean [read-write]The default value is true.
public function get enabled():Boolean
public function set enabled(value:Boolean):void
separatorBefore:Boolean [read-write]Note: A separator bar always appears between any custom menu items and the built-in menu items.
The default value is false.
public function get separatorBefore():Boolean
public function set separatorBefore(value:Boolean):void
visible:Boolean [read-write]The default value is true.
public function get visible():Boolean
public function set visible(value:Boolean):void
flash.events.ContextMenuEvent
flash.events.ContextMenuEvent.MENU_ITEM_SELECT
menuItemSelect event when a user selects an item from a context menu.
The user generates the context menu by clicking the secondary button of the user's pointing device.
This event has the following characteristics:
| Properties | Values |
|---|---|
target | The ContextMenuItem object that has been selected.
The target is not always the object in the display list
that registered the event listener. Use the currentTarget
property to access the object in the display list that is currently processing the event. |
bubbles | No. |
currentTarget | Indicates the object that is actively processing the Event object with an event listener. |
cancelable | No. There is no default behavior to cancel. |
public function ContextMenuItem(caption:String, separatorBefore:Boolean = false, enabled:Boolean = true, visible:Boolean = true)
ContextMenu.customItems
array.
Parameters
caption:String — Specifies the text associated with the menu item.
See the ContextMenuItem class overview for caption value restrictions.
|
|
separatorBefore:Boolean (default = false) — Specified whether a separator bar appears above the
menu item in the context menu. The default value is false.
|
|
enabled:Boolean (default = true) — Specifies whether the menu item is enabled or disabled in the
context menu. The default value is true. This parameter is optional.
|
|
visible:Boolean (default = true) — Specifies whether the menu item is visible or invisible. The
default value is true.
|
public function clone():ContextMenuItem
ContextMenuItem —
A ContextMenuItem object that contains all the properties of the original object.
|
ContextMenuBuiltInItemsExample
to remove the normal right-click menu items from the stage and add a new menu item. This is
accomplished using the following steps:
myContextMenu is declared and then assigned to a new ContextMenu
object.removeDefaultItems() is called, which removes all built-in right-click
menu items except print.addCustomMenuItems() is called, which places an item called
Hello World menu selection into the customItems Array using the
push() method of Array.Hello World right-click menu item is then added to the stage's right-click
menu item list.addChild() via createLabel().
package {
import flash.ui.ContextMenu;
import flash.ui.ContextMenuItem;
import flash.display.Sprite;
import flash.text.TextField;
public class ContextMenuItemExample extends Sprite {
private var myContextMenu:ContextMenu;
public function ContextMenuItemExample() {
myContextMenu = new ContextMenu();
removeDefaultItems();
addCustomMenuItems();
this.contextMenu = myContextMenu;
addChild(createLabel());
}
private function removeDefaultItems():void {
myContextMenu.hideBuiltInItems();
var defaultItems:ContextMenuBuiltInItems = myContextMenu.builtInItems;
defaultItems.print = true;
}
private function addCustomMenuItems():void {
var item:ContextMenuItem = new ContextMenuItem("Hello World");
myContextMenu.customItems.push(item);
}
private function createLabel():TextField {
var txtField:TextField = new TextField();
txtField.text = "Right Click";
txtField.x = this.stage.stageWidth/2 - txtField.width/2;
txtField.y = this.stage.stageHeight/2 - txtField.height/2;
return txtField;
}
}
}
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/labs/flashauthoringpreview/flash/ui/ContextMenuItem.html