ActionScript - Context Menus

Most Windows applications provide context menus that are displayed when you click the right mouse button. Flash supports a similar capability ... except that there are 2 menu options that can not be removed - Settings and About Flash.

The basic procedure is to

This allows each Button, Text Field, etc to have its own context menu.


Form Context Menu

Adding a context menu to the form itself follows the same procedure. The help explicitly states that you can not use the built-in context menu - instead you must create one and attach it to ...... ? Well, that's not real clear.

You are not allowed to assign a context menu to the stage (though the help file says you can) - I tried, it produces an error.

As shown below, just create a new context menu and then assign it to the application variable. (Notice that the first *c* is capitalized in one case and not the other.)


Adding *About*

When you create a project, you should add your name to it ... or at least some descriptive information. This example shows how to add an About... selection to the context (right click) menu. The following code

Note - navigateToURL fails when opening a web page locally (normal security setting), but works fine when the swf file is read from a server. It also works when running inside the Flash CS3 IDE.


Author: Robert Clemenzi - clemenzi@cpcug.org
URL: http:// cpcug.org / user / clemenzi / technical / Languages / ActionScript / Context_Menus.html