OK 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:

This movie requires Flash Player 10

Nice post about The Right-Click Menu in Flash by Raiyan

Creative Commons License
This work, unless otherwise expressly stated, is licensed under a Creative Commons Attribution 2.5 Bulgaria License.