Every InteractiveObject (e.g. Application, Panel, Button, etc) contains a contextMenu property. For most components it will be null and you'll have to create a new menu and assign it to that property. So you can have different context menus for different components.
Here is a simple example of a context menu set on the application:
Here is a short snippet from the above example showing you have to create a ContextMenu, hide the built-in menu items, and listen for menu events.
There are many restrictions to Flex ContextMenus, some of which will drive you crazy. Read carefully, it will save you time later.
- Maximum of 15 custom menu items in the menu
- No sub-menus allowed
- No icons in menus
- Menu items must be 100 characters or less
- Control characters, newlines, and other white space characters are ignored
- MANY reserved words including (but not limited to):
- Zoom In
- Zoom Out
- Show All
- Movie not loaded
- Show Redraw Regions
- Select All
- Open in new window
- Copy link
- Copy Link Location
More details about the restrictions can be found on the ContextMenuItem page.
Here is one such solution: Custom Context Menu.
These solutions can work quite effectively, but since they depend on the browser they can be quite buggy.