Multiple ContextMenuItem for different objects
Posted in AS3 optimization, example, projects & snippets on August 11th, 2010 by admin – Be the first to commentOK here is a simple way to create as many objects as you want context menus:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | import flash.ui.ContextMenu; import flash.ui.ContextMenuItem; function addContext(sprite_:Sprite):void { var menu:ContextMenu = new ContextMenu(); menu.customItems = [new ContextMenuItem("Select only " + sprite_.name)]; menu.hideBuiltInItems(); sprite_.contextMenu = menu; } addContext(yellow); addContext(green); addContext(red); addContext(blue); addContext(this); |
note that yellow, green, red, blue are Sprites, but it can be also buttons
Example:
Nice post about The Right-Click Menu in Flash by Raiyan





