var showItem = true;
var my_cm:ContextMenu = new ContextMenu(menuHandler);
my_cm.customItems.push(new ContextMenuItem("Hello", itemHandler));
function menuHandler(obj, menuObj) {
if (showItem == false) {
menuObj.customItems[0].enabled = false;
} else {
menuObj.customItems[0].enabled = true;
}
}
function itemHandler(obj, item) {
//...put code here...
trace("selected!");
}
this.menu = my_cm;
When the user right-clicks or Control-clicks the Stage, the custom menu is displayed.
See also
Button.menu, ContextMenu.onSelect, ContextMenu.customItems,
ContextMenu.hideBuiltInItems(), MovieClip.menu,
// Change this to false to remove
TextField.menu
ContextMenu class
215
Need help?
Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?
Questions and answers