View comments | RSS feed

ContextMenu.onSelect

Availability

Flash Player 7.

Usage

my_cm.onSelect = function (item:Object, item_menu:ContextMenu) : Void{
   // your code here
}

Parameters

item 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 A reference to the ContextMenu object assigned to the menu property of object.

Returns

Nothing.

Description

Event handler; called when a user invokes the Flash Player context menu, but before the menu is actually displayed. This lets you customize the contents of the context menu based on the current application state.

You can also specify the callback handler for a ContextMenu object when you construct a new ContextMenu object. For more information, see the ContextMenu class entry.

Example

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

my_cm = 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;

Comments


No screen name said on Jun 28, 2005 at 12:41 PM :
Observe! This function requires your project to be compiled to AS2. Using Flash Player 7 and plain ActionScript will NOT trigger this event!

A bug in the FireFox version of the Flash Player allows buttons to be trigged before the event called as the menu disappears, thus allowing input from underlying buttons!
Helper Bee said on Jul 11, 2005 at 6:37 PM :
All examples in the book assume AS2 unless stated otherwise. This is noted in one of the first pages in the doc: The examples are written in ActionScript 2.0, and will be unlikely to compile if you have specified ActionScript 1.0 or Flash Player 5 or earlier in the Flash tab of your FLA file's Publish Settings dialog box.

 

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

Current page: http://livedocs.adobe.com/flash/mx2004/main_7_2/00001281.html