Her

Home Flash & Swish Flash Tutorials Change The Right Click Menu

Change The Right Click Menu

Author: Tutorial Scene Author's URL: www.tutorialscene.com More by this author

Requirements

  • Flash MX2004 or higher.

Preview

1. Start by creating a new flash document or opening one you wish to add this functionality to.

2. Select frame 1 and press F9 to open the Actions Panel.

3. Now add the following code.

function menuChoiceOne() //Called when Choice One is clicked
{
        getURL("http://www.tutorialscene.com"); //Takes you to tutorialscene.com
}
function menuChoiceTwo() //Called when Choice Two is clicked
{
        //Does nothing
}
cmNew = new ContextMenu(); //Creates a new right click menu
cmNew.hideBuiltInItems(); //Hides the built in items
cmNew.customItems.push(new ContextMenuItem("Choice One", menuChoiceOne)); //Adds a new item on the right click menu named Choice One that calls menuChoiceOne() when pressed.
cmNew.customItems.push(new ContextMenuItem("Choice Two", menuChoiceTwo)); //Adds a new item on the right click menu named Choice Two that calls menuChoiceTwo() when pressed.
this.menu = cmNew; //Sets the right click menu in the flash movie to the one you just created

4. To have the right click menu not have any custom items on it delete the lines:

cmNew.customItems.push(new ContextMenuItem("Choice One", menuChoiceOne));
cmNew.customItems.push(new ContextMenuItem("Choice Two", menuChoiceTwo));

5. To change the text that is shown by the choices change "Choice One" to "Your Text Goes Here" or "Choice Two" to "Your Text Goes Here"

6. To change what happens when the choices are clicked, change what the functions that are called do.

7. To add more choices to the right click menu, first define a new function named "menuChoiceThree" then add another line like

cmNew.customItems.push(new ContextMenuItem("Choice Three", menuChoiceThree));

8. You should be able to test your movie now and use your right click menu.