Latest tutorial: Premium Flash Files | Ask Tutorial5! | Subscribe to RSS Register Login Find Hobbies
Advertisement

Get tutorials on EMail




Do you need more help? You can now Ask Tutorial5! and get free support - Ask a question now!

Customize right click menu in Flash

(17 votes)
Written by AnaS   

Let's begin!

1. Create a new Adobe Flash 8 document with 300x300 dimensions

Insert two new layers and give them the following names: actions, message and movie, starting from the top to bottom.

flashcontextmenu1.gif

2. Draw a rectangle

In the first frame of the movie layer using the Rectangle Tool (R) draw a rectangle about 250x150 and set a blue for the Fill Color and no color for the Stroke Color.

3. Select the rectangle

Choose Modify >> Convert to Symbol (F8). In the Convert to Symbol window set values like in the image below:

flashcontextmenu2.gif

4. Select the MovieClip you just created

Go in the Properties panel and give it an instance name of context_mc.

5. Make a text field on the stage

Go in the first frame of the message layer. Using the Text Tool (T) from the Tools panel make a text field on the stage, in top of the context_mc. In the Properties panel set the following properties for the text field: Text Type: Dynamic Text, instance name: message_txt, font: Verdana, size: 43, bold, text color #0066CC.

flashcontextmenu3.gif

6. Action Script code

Go in the first frame of the actions panel and let's put some ActionScript:

/* these are the functions to be called from the right-click menu */

function menu1()
{
getURL("http://www.tutorial5.com/");
}
function menu2()
{
getURL("http://www.rentahobby.com/");
}
function menu3()
{
message_txt._visible=true;
}
function menu4()
{
message_txt._visible=false;
}

/* create a new ContextMenu object*/

contextMenu = new ContextMenu();
contextMenu.hideBuiltInItems(); // hides the build-in menu items (except Settings)
contextMenu.customItems.push(new ContextMenuItem("Tutorial5.com - 5 stars tutorials", menu1)); // insert new menu items
contextMenu.customItems.push(new ContextMenuItem("rentahobby.com - Find a hobby", menu2));
contextMenu.customItems.push(new ContextMenuItem("Show message", menu3));
contextMenu.customItems.push(new ContextMenuItem("Hide message", menu4));
context_mc.menu = contextMenu; // associates the contextMenu with context_mc

 

7. Now just test the movie (Ctrl+Enter)

You can see that the custom Flash context menu appears when your mouse is over the context_mc, if you are outside context_mc the standard menu appears when you right click. Hope this tutorial helps!

You need to Register in order to download the FLA file.



Subscribe now via RSS feed and get all the new tutorials

written by Nazmul , November 06, 2007

thanks
i learned something new!!
written by Hendro Agus , December 11, 2007

hi, how to remove setting and about menu's ??
well, this tutorial is very good..
but, it would be nice if you tell fully own context menu...
and there are no existing menu from default of flash
it is pure we create the customize right click menu's

please advise and can you respond it into my Email to?

FYI, presently i'm trying to make a blog on geocities..
could you want to see my blog?
this is the URL

http://geocities.com/ndro_agus

regards
hendro
written by ddieguez , January 06, 2008

great tutorial, it helped me a lot. Thanks :D

Do you need more help? Ask now!
 

busy
Last Updated ( Friday, 28 March 2008 )