« I'm a SheHe | Main | View Remoting Logs? »

Context Menu Gotcha

Stumbled across what I would consider an odd gotcha with ContextMenu's that I didn't see documented when I searched anywhere. You are allowed 15 custom items for a context menu. In flash 7 - it appears that the separatorBefore = true , when applied to a custom item , is considered a customItem. IN flash 8 this is not the case. In fact, both players will show the customItems, but in 7, items over the 15 limit will not fire the callback assigned.

Here is some code to illustrate. It will work in 8 perfectly fine. Not the case in 7.

// WORKS IN BOTH 7 and 8
var my_cm:ContextMenu = new ContextMenu();

for (var i = 1; i<=16; i++) {
var menuItem_cmi:ContextMenuItem = new ContextMenuItem("Item"+i,shoutingOut);

my_cm.customItems.push(menuItem_cmi);

}
this.menu = my_cm;
this.menu.hideBuitInItems();

function shoutingOut() {
trace("shout out");
}

// DOES NOT WORK IN 7

var my_cm:ContextMenu = new ContextMenu();

for (var i = 1; i<=16; i++) {
var menuItem_cmi:ContextMenuItem = new ContextMenuItem("Item
"+i, shoutingOut);
if (!(i%2)) {
menuItem_cmi.separatorBefore = true;
}
my_cm.customItems.push(menuItem_cmi);

}
this.menu = my_cm;
this.menu.hideBuiltInItems();
function shoutingOut() {
trace("shout out");
}

//---------------
Sorry about the code formatting, I need to get something going on that.

Posted by bitch at October 31, 2005 02:33 AM

Comments




Remember Me?