Tutorial: How to change the Flash context menu
Every Flash movie has a mouse ‘right-click’ context menu with items like “About Adobe Flash … ” etc. – you may not know you can add your own entries. This tutorial tells you how.
You may have wished that the right click context menu offered options other than the standard:
- Zoom In,
- Zoom Out,
- Show All,
- Quality,
- Print…,
- Settings…,
- Global Settings… &
- About Adobe Flash Player XX…
Fortunately the menu can be altered with a small amount of scripting. The ContextMenu and ContextMenuItem Classes added to Flash Player 7+ allow the context menu to be altered. Although the SWiSH Max help manual does not describe these classes, Max3 is fully Action Script 2.0 compliant hence any commands outlined in the Action Script 2.0 reference should work.
The sample code below shows how to disable most of the menu items and add your own copyright notice. This script could be easily modified to perform different actions by modifying the gotosz function. Alternatively additional functions and menu items could be added. The Settings, Global Settings and About Flash items cannot be disabled.
For more detailed modifications, see the description of the ContextMenu and ContextMenuItem classes within the AS 2.0 reference mentioned above.
function gotosz() {
// menu select handler
// open main swishzone.com webpage
getURL("http://www.swishzone.com", "_blank");
}
onSelfEvent (load) {
// create an object for our revised context menu
var mymenu:ContextMenu = new ContextMenu();
// hide the normal zoom, quality etc. items.
// note that settings and about cannot be hidden
mymenu.hideBuiltInItems();
// create our own menu item for a copyright message.
var copyright:ContextMenuItem = new ContextMenuItem();
copyright.caption = "(c) SWiSHzone.com"; // caption
copyright.onSelect = gotosz; // define handler function
// add our copyright menu item
mymenu.customItems.push(copyright);
// update the context menu for the main movie
this.menu = mymenu;
}
An example movie with modified context menu is shown below:
The source for the sample movie can be downloaded here.
Care should be taken not to base your user interface too heavily on the context menu as Mac users without a second mouse button will be unable to access such menus.



Hi!
About this topic, a week ago, I formulated a tricky use with this source at the swish forum (http://forums.swishzone.com/index.php?showtopic=71568) but I don’t have a succesfull answer yet. Could You please help me?
Thank you!! :)
Hi,
I had a look at your forum topic and I am not sure what you are trying to achieve. Could you please attach a sample .swi to the forum topic.
Jon
Thanks John!
I just attached the three files (http://forums.swishzone.com/index.php?showtopic=71568&st=0&gopid=304719&#entry304719):
1) With the Magnet Script
2) With the Flash context menu
and
3) With Both (When both are used at the same time, the Flash context menu, is disabled) and I need to work them together.
Thanks!!
Hi,
I have looked at the movies and posted what I think fixes the problem at the forum.
Jon