Tutorial: How to change the Flash context menu

1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, average: 5.00 out of 5)

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

    // 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

    // 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.

Tags: ,

4 Responses to “Tutorial: How to change the Flash context menu”

  1. Tat Sanchz says:


    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!! :)