Removing Context Menu from Flex Menu, Drag, and PopUp

I have had a long standing problem that has been plaguing one of my recent projects.   I wanted to remove the ContextMenu right-click items.   The way it would normally be done is to create a new ContextMenu and then use the hideBuiltInItems(); to remove all the items from the right-click menu except for the Settings and About information for the Flash Player:

// hide right-click menu items
var menu:ContextMenu = new ContextMenu();
this.contextMenu = menu;

Placing this code in the main application file for your Flex project seems to work, at first.   Then you realize that you while dragging items, you can quickly right-click and see the full Flash Player menu.   I also found that if you right-click on a Flex Menu item the full Flash Player menu will also be visible.   Thinking this was some sort of bug, I posted it to FlexCoders.  I waited and waited for any response, but got bupkus, nada, crickets.   However,  just by chance, I ran across Adobe’s Flex cookbook beta web site today and there was a post titled “Removing the context menu build in items from pop up windows”.  Holy Cow!! 

Apparently, Popup windows (and I imagine Menus and Drag objects) are children of the SystemManager, not the Application.  They will just ignore the regular command for removing the right-click menu. You have to remove the ConextMenu by using additional code in your main application file:

//Remove ContextMenu from all SystemManager Menu items and PopUp
MovieClip(systemManager).contextMenu = this.contextMenu.clone();

This makes the context menu of the SystemManager the same as that of the Application.  Thanks “aalderson”, whoever you are, you rock!


  1. I’m having this problem: I set up a context menu to work with a Tree object, but the EventListeners do not work. The context menu appears, but when I click an item, nothing happens. It works with other controls, just not the Tree. I read that some controls disallow MouseEvents on their children/items, so you have to create a custom item renderer or extend the item renderer class to allow MouseEvents on the items in the list. Do you know if this applies to the Tree control, or do you have any other information that might help me?


  2. What about removing the Context Menu from Flash using CS3?

    systemManager is not defined in Flash.

    Is this possible?

  3. Mike,

    Yeah, I think I read about this on Flex Coders group. Search the archives there for custom tree controls or contextual menus.

  4. Hi. I’m trying to setup a context menu for a Tree control where the context menu is different for right-clicking on a folder item or leaf item. However, it doesn’t do that. It just displays the set of menu items defined (lastly, in an If…else construct) for the leaf items.

    How can I resolve this? Thanks

  5. I just copy pasted ur code “MovieClip(systemManager).contextMenu = this.contextMenu.clone(); ” in app.but still it is showing contex menu on text bar.I am using flex 2.0.1

  6. Hello,I have a problem :it still displays the default menu items,even though I have done as what you told. so, could you please help me to have a look at my codes:

    Thanks very much.

  7. systemManager is a property of the main application. In order to do this, put the code in your main application MXML file or use the Application singleton like so:

    MovieClip(Application.application.systemManager).contextMenu = Application.application.contextMenu.clone();

    Good luck


  8. hello,

    i have a project for a script which is like youtube. i need to remove some information from the player. the player files comes with swf not with fla.

    how we can change that context menu by using swf file not the fla, is there any way that we convert the swf to fla and then export it back to swf file?

  9. Hi,

    II tried your code and it removes the Print Item. But other 3 remain. Settings, Global Settings and About Adobe…

    Can I remove this items also.

    I tried both
    [as]MovieClip(systemManager).contextMenu = this.contextMenu.clone();[/as]


    [as]var contextMenu:ContextMenu = new ContextMenu();
    this.contextMenu = contextMenu;[/as]

    Many thanks for you attention


Comments are closed.