Our Flash tutorials provide you with step-by-step instructions on how to create beautiful Flash animations and integrate them into your website.  Home Flash & Swish Flash Tutorials Change The Right Click Menu

Change The Right Click Menu


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.




Author's URL: Tutorial Scene
Final results of our readers
New!
Passed through all the steps? Share your result!
Your result will be premoderated.
Please make sure you choose the right image.
 
 



Captcha

*Required fileds
Our Flash tutorials provide you with step-by-step instructions on how to create beautiful Flash animations and integrate them into your website. More Flash Tutorials: Featured Materials | Fresh Materials | More Flash Tutorials at FlashPerfection.com

Reader's comments
comments AlexA August 05, 2011 says:
Thanks. :)
Reply
comments pHeR-d April 20, 2007 says:
I like this tutorial. Thanks all.
Here is a tip: If you want just remove the Zoom In, out etc. u can use following code:

[code]cmNew = new ContextMenu(); //Creates a new right click menu
cmNew.hideBuiltInItems(); //Hides the built in items
this.menu = cmNew; //Sets the right click menu in the flash movie to the one you just created

Reply
Add comments to "Change The Right Click Menu"

Captcha