In this tutorial you will learn how to disable the right click context menu when a flash movie clips is running. The context menu by default contains the following: zoom in, 100%, show all, quality and print. The default menus could affect the overall look and flow of the Flash file created by the developer, so disabling the context menu can remove any inconveniences or problems.
You will need to use the ContextMenu class for this tutorial, more information on this class can be found at the ContextMenu AS3 component reference.
Disable context menu in Actionscript 3
Open a new Flash AS3 file.
Select Ctrl + Enter and right click on the stage and you should see the following:
**This is the default context menu on the stage.
Now, time to remove the default context menu. Hit F9 to open up the actions panel and enter the following code:
var my_cMenu:ContextMenu = new ContextMenu();
contextMenu = my_cMenu;
1. Creates an instance of the ContextMenu class with the variable name ‘my_cMenu’ which will reference the content menu.
2. The ‘hideBuiltItems’ method hides all the default items in the context menu.
3. This sets the item to the property which will hide all the menu items.
Test the movie clip Ctrl + Enter. You should notice the default menu items have now been moved, but the items in the following image below cannot be removed.
Why not checkout the custom context menu tutorial ?