This example demonstrates how to create right click menu for an item in Flash movie.
Download source project here (3 kb)
- Launch Alligator Flash Designer and choose Blank
- Set movie dimensions to 460 x 180 (or any desired) with Frame > Frame Size
- Choose “Movie” > “Export Options” > “Frame Rate” and set target player version: Flash Player 8

- Change frame delay to “Stop”.
- Choose Sprite tool and draw a sprite, double click the sprite to edit it
- Inside the sprite draw a rectangle and apply any color to it, for example yellow
- Hit Esc to quit the sprite
- Select the sprite and press F2 to rename the sprite, the name should be Sprite1

- Choose Frame > ActionScript and paste the script
// create new context menu mymenu = new ContextMenu(); // hide items like Zoom, Play, Loop etc mymenu.hideBuiltInItems(); // define menu item handler function doFrame2() { gotoAndPlay("Frame 2");} // create new menu item and add it to the right click menu frame2item = new ContextMenuItem("Frame 2", doFrame2); mymenu .customItems.push(frame2item); // set the menu for sprite 1 Sprite1.menu = mymenu; - Add a new Frame that will appear as “Frame 2″ and put anything on it, for example text “Frame 2″
- Hit F9 for preview. Right-click anywhere outside the rectangle to view default menu, right-click on the rectangle to open “mymenu”. Choose “Frame 2″ from the context menu to go to Frame 2.




January 15, 2010
Actionscript 3.0 Tutorial