ContextMenu.callback

Availability

Flash Player 7.

Usage

myMenu.callback = callBackFunction

Parameters

myMenu An instance of the ContextMenu object.

callBackFunction An identifer for the callback handler.

Returns

Nothing.

Description

Method; invoked when a user invokes the Flash Player context menu, but before the menu is displayed. You are thus able to modify the contents of a context menu based on current application state.

The specified callback function must have the following signature:

function callBackFunction (obj:Object, menu:ContextMenu) {
	// ... handler body
}

The obj parameter that is passed to the callback function is a reference to the object (movie clip, button, or selectable text field) that was under the mouse when the Flash Player context menu was invoked. The menu parameter is the ContextMenu object associated with the obj object.

You can also set the callback handler for a ContextMenu object when you create the ContextMenu object. For more information, see the ContextMenu object entry.

Example

myMenu = new ContextMenu();
myMenu.callback = menuHandler;
menuHandler = function (obj:Object, menu:ContextMenu) {
	if(obj instanceof MovieClip) {
		trace("Movie clip: " + obj);
	}
	if(obj instanceof TextField) {
		trace("Text field: " + obj);
	}
	if(obj instanceof Button) {
		trace("Button: " + obj);
	}
}