View comments | RSS feed

onSelect (ContextMenu.onSelect handler)

onSelect = function(item:Object, item_menu:Object) {}

Called when a user invokes the Flash Player context menu, but before the menu is actually displayed. This event handler allows customization of the contents of the context menu based on the current application state.

It is also possible to specify the callback handler for a ContextMenu object when constructing a new ContextMenu object. For more information, see the ContextMenuItem onSelect entry.

Availability: ActionScript 1.0; Flash Player 7

Parameters

item:Object - A reference to the object (movie clip, button, or selectable text field) that was under the mouse pointer when the Flash Player context menu was invoked and whose menu property is set to a valid ContextMenu object.

item_menu:Object - A reference to the ContextMenu object assigned to the menu property of object.

Example

The following example determines over what type of object the context menu was invoked.

my_cm:ContextMenu = new ContextMenu();
function menuHandler(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);
    }
}
my_cm.onSelect = menuHandler;
my_mc.menu = my_cm;
my_btn.menu = my_cm;

Flash CS3


Comments


No screen name said on May 24, 2007 at 10:59 AM :
if you get an error using the above code, it's because you need to use the keyword "var" with strict data typing, so change the first line to this:

var my_cm:ContextMenu = new ContextMenu();

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/9.0/main/00001554.html