| Package | flash.events |
| Class | public class ContextMenuEvent |
| Inheritance | ContextMenuEvent Event Object |
ContextMenuEvent.MENU_ITEM_SELECTContextMenuEvent.MENU_SELECT| ContextMenu class, ContextMenuItem class, ContextMenuEvent.MENU_ITEM_SELECT, ContextMenuEvent.MENU_SELECT |
| Property | Defined by | ||
|---|---|---|---|
![]() | ACTIVATE : String = "activate" [static]
Dispatched when Flash Player gains operating system focus and becomes active.
| Event | |
![]() | ADDED : String = "added" [static]
Dispatched when a display object is added to the display list.
| Event | |
![]() | CANCEL : String = "cancel" [static]
Dispatched when a file upload or download is cancelled by the user.
| Event | |
![]() | CHANGE : String = "change" [static]
Dispatched after a control's value is modified.
| Event | |
![]() | CLOSE : String = "close" [static]
Dispatched by an Socket or XMLSocket object after a network connection is closed.
| Event | |
![]() | COMPLETE : String = "complete" [static]
Dispatched when data has loaded successfully.
| Event | |
![]() | CONNECT : String = "connect" [static]
Dispatched when a network connection has been established.
| Event | |
![]() | DEACTIVATE : String = "deactivate" [static]
Dispatched when Flash Player loses operating system focus and is
becoming inactive.
| Event | |
![]() | ENTER_FRAME : String = "enterFrame" [static]
Dispatched when the playhead is entering a new
frame.
| Event | |
![]() | ID3 : String = "id3" [static]
Dispatched by a Sound object when ID3 data is available for an MP3 sound.
| Event | |
![]() | INIT : String = "init" [static]
Dispatched by a LoaderInfo object when the properties and methods of a loaded SWF file are
accessible.
| Event | |
| MENU_ITEM_SELECT : String = "menuItemSelect" [static]
Flash Player dispatches the
menuItemSelect event when a user selects an item from a context menu. | ContextMenuEvent | ||
| MENU_SELECT : String = "menuSelect" [static]
Flash Player dispatches the
menuSelect event when a user first generates a
context menu but before the contents of the context menu are displayed. | ContextMenuEvent | ||
![]() | MOUSE_LEAVE : String = "mouseLeave" [static]
Dispatched by the Stage object when the mouse pointer moves out of the Flash Player
window area.
| Event | |
![]() | OPEN : String = "open" [static]
Dispatched by a LoaderInfo, URLLoader, URLStream or FileReference object when a network
operation starts.
| Event | |
![]() | REMOVED : String = "removed" [static]
Dispatched when a display object is about to be removed from the display list.
| Event | |
![]() | RENDER : String = "render" [static]
Dispatched when the display list is about to be updated and rendered.
| Event | |
![]() | RESIZE : String = "resize" [static]
Dispatched when
scaleMode property of the Stage object is set to
StageScaleMode.NO_SCALE and the SWF file has been resized. | Event | |
![]() | SCROLL : String = "scroll" [static]
Dispatched by a TextField object after the user scrolls.
| Event | |
![]() | SELECT : String = "select" [static]
Dispatched by a FileReference object when an item has been selected.
| Event | |
![]() | SOUND_COMPLETE : String = "soundComplete" [static]
Dispatched by a Sound object when a sound has finished playing.
| Event | |
![]() | TAB_CHILDREN_CHANGE : String = "tabChildrenChange" [static]
Dispatched by an InteractiveObject instance when the value of the object's
tabChildren flag changes. | Event | |
![]() | TAB_ENABLED_CHANGE : String = "tabEnabledChange" [static]
Dispatched by an InteractiveObject instance when the the object's
tabEnabled flag changes. | Event | |
![]() | TAB_INDEX_CHANGE : String = "tabIndexChange" [static]
Dispatched by an InteractiveObject instance when the
value of the object's
tabIndex property changes. | Event | |
![]() | UNLOAD : String = "unload" [static]
Dispatched by a LoaderInfo object whenever a loaded object is removed using the
unload()
method of the Loader object, or when a second load is performed by the same Loader object and the
orignal content is removed prior to the load beginning. | Event | |
| Property | Defined by | ||
|---|---|---|---|
![]() | bubbles : Boolean
Indicates whether an event is a bubbling event.
| Event | |
![]() | cancelable : Boolean
Indicates whether the behavior associated with the event can be prevented.
| Event | |
![]() | constructor : Object
A reference to the class object or constructor function for a given object instance.
| Object | |
| contextMenuOwner : InteractiveObject
The display list object to which the menu is attached.
| ContextMenuEvent | ||
![]() | currentTarget : Object
Indicates the object that is actively processing the Event object with an event listener.
| Event | |
![]() | eventPhase : uint
Indicates the current phase in the event flow.
| Event | |
| mouseTarget : InteractiveObject
The display list object on which the user context-clicked to display the context menu.
| ContextMenuEvent | ||
![]() | prototype : Object
[static]
A reference to the prototype object of a class or function object.
| Object | |
![]() | target : Object
Indicates the event target.
| Event | |
![]() | type : String
Indicates the type of event.
| Event | |
| Function | Defined by | ||
|---|---|---|---|
|
ContextMenuEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, mouseTarget:InteractiveObject = null, contextMenuOwner:InteractiveObject = null)
Creates an Event object that contains specific information about menu events.
| ContextMenuEvent | ||
|
Creates a copy of the ContextMenuEvent object and sets the value of each property to match that of the original.
| ContextMenuEvent | ||
![]() |
A utility function that you use to implement the
toString() method in your custom Event class. | Event | |
![]() |
Indicates whether an object has a specified property defined.
| Object | |
![]() |
This method checks whether
preventDefault() has been called on the event and
returns true if preventDefault() has been called and
false otherwise. | Event | |
![]() |
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter.
| Object | |
![]() |
Cancels an event's default behavior if that behavior can be cancelled.
| Event | |
![]() |
Indicates whether the specified property exists and is enumerable.
| Object | |
![]() |
Sets the availability of a dynamic property for loop operations.
| Object | |
![]() |
Prevents processing of any event listeners in the current node and any subsequent nodes in
the event flow.
| Event | |
![]() |
Prevents processing of any event listeners in nodes subsequent to the current node in the
event flow.
| Event | |
|
Returns a string that contains all the properties of the ContextMenuEvent object.
| ContextMenuEvent | ||
![]() |
Returns the primitive value of the specified object.
| Object | |
public static const MENU_ITEM_SELECT:String = "menuItemSelect"
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. |
| flash.ui.ContextMenuItem |
public static const MENU_SELECT:String = "menuSelect"
menuSelect event when a user first generates a
context menu but before the contents of the context menu are displayed. The user can then
modify the set of context menu items based on the mouseTarget before
displaying the 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 ContextMenu object that is about to be displayed.
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. |
| flash.ui.ContextMenu |
contextMenuOwner:InteractiveObject [read-write]mouseTarget) or one of its ancestors in the display list.
public function get contextMenuOwner():InteractiveObject
public function set contextMenuOwner(value:InteractiveObject):void
mouseTarget:InteractiveObject [read-write]contextMenuOwner) or one of its display list descendants.
public function get mouseTarget():InteractiveObject
public function set mouseTarget(value:InteractiveObject):void
public function ContextMenuEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, mouseTarget:InteractiveObject = null, contextMenuOwner:InteractiveObject = null)
type:String — The type of the event. Possible values are:
|
|
bubbles:Boolean (default = false) — Determines whether the Event object participates in the bubbling stage of the event flow. Event listeners can access this information through the inherited bubbles property.
|
|
cancelable:Boolean (default = false) — Determines whether the Event object can be cancelled. Event listeners can access this information through the inherited cancelable property.
|
|
mouseTarget:InteractiveObject (default = null) — The display list object on which the user context-clicked to display the context menu. This could be the contextMenuOwner or one of its display list descendants.
|
|
contextMenuOwner:InteractiveObject (default = null) — The display list object to which the menu is attached. This could be the mouseTarget or one of its ancestors in the display list.
|
| ContextMenuEvent.MENU_ITEM_SELECT, ContextMenuEvent.MENU_SELECT |
public override function clone():Event
Event —
A new ContextMenuEvent object with property values that match those of the original.
|
public override function toString():String
[ContextMenuEvent type=value bubbles=value cancelable=value ... contextMenuOwner=value]
String —
A string that contains all the properties of the ContextMenuEvent object.
|
ContextMenuEventExample class
to remove the normal right-click menu items from the stage and add a new menu item, which, if
clicked, changes the color of a square on the stage. This is accomplished using the following
steps:
myContextMenu is declared and then assigned to a new ContextMenu
object and a property redRectangle of type Sprite is declared.removeDefaultItems() is called, which removes all built-in right-click
menu items except print.addCustomMenuItems() is called, which places an item called
Reverse Colors menu selection into the defaultItems Array using the
push() method of Array. A menuItemSelect event listener is added to the
ContextMenuItem object and the associated method is called menuItemSelectHandler().
This method prints out some statements using trace() whenever the
right-click menu is accessed and Reverse Colors is selected. Also the red square
is turned black while the black text is turned red.menuSelect is added, along with
the associated method menuSelectHandler, which simply prints out three statements using
trace() every time an item in the right-click menu is opened (by right-clicking).addChildren(), which draws a red square and adds it
to the display list, which promptly displays it.myContextMenu is assigned to the redRectangle property's context menu
so that the custom context menu is displayed only when the mouse is over the square.
package {
import flash.ui.ContextMenu;
import flash.ui.ContextMenuItem;
import flash.events.ContextMenuEvent;
import flash.events.ContextMenuEvent;
import flash.display.Sprite;
import flash.display.Shape;
import flash.text.TextField;
public class ContextMenuEventExample extends Sprite {
private var myContextMenu:ContextMenu;
private var menuLabel:String = "Reverse Colors";
private var textLabel:String = "Right Click";
private var redRectangle:Sprite;
private var label:TextField;
private var size:uint = 100;
private var black:uint = 0x000000;
private var red:uint = 0xFF0000;
public function ContextMenuEventExample() {
myContextMenu = new ContextMenu();
removeDefaultItems();
addCustomMenuItems();
myContextMenu.addEventListener(ContextMenuEvent.MENU_SELECT, menuSelectHandler);
addChildren();
redRectangle.contextMenu = myContextMenu;
}
private function addChildren():void {
redRectangle = new Sprite();
redRectangle.graphics.beginFill(red);
redRectangle.graphics.drawRect(0, 0, size, size);
addChild(redRectangle);
redRectangle.x = size;
redRectangle.y = size;
label = createLabel();
redRectangle.addChild(label);
}
private function removeDefaultItems():void {
myContextMenu.hideBuiltInItems();
var defaultItems:ContextMenuBuiltInItems = myContextMenu.builtInItems;
defaultItems.print = true;
}
private function addCustomMenuItems():void {
var item:ContextMenuItem = new ContextMenuItem(menuLabel);
myContextMenu.customItems.push(item);
item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, menuItemSelectHandler);
}
private function menuSelectHandler(event:ContextMenuEvent):void {
trace("menuSelectHandler: " + event);
}
private function menuItemSelectHandler(event:ContextMenuEvent):void {
trace("menuItemSelectHandler: " + event);
var textColor:uint = (label.textColor == black) ? red : black;
var bgColor:uint = (label.textColor == black) ? black : red;
redRectangle.graphics.clear();
redRectangle.graphics.beginFill(bgColor);
redRectangle.graphics.drawRect(0, 0, size, size);
label.textColor = textColor;
}
private function createLabel():TextField {
var txtField:TextField = new TextField();
txtField.text = textLabel;
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/events/ContextMenuEvent.html