Your Ad Here

December 18, 2010

Context Menu in Flash


Category: Advance
Actionscript: 2.0


  In this tutorial related to Adobe Flash you will learn how to disable context menu and customize it. There are separate scripts or methods for Disabling and Customizing Context Menu.

 Both the scripts are given below.

Disable Context Menu For Projector Files:
                If you want export your file as .swf or .exe file and use it as it is then you can use this command to disable context menu in Adobe Flash.

1- Open up Macromedia Flash and create a new file.
2- Select 1st frame from any layer. Better to make a separate layer for actions.
3- While the frame is still selected open up the Actions Panel (F9) and write the actions as follows:

fscommand("showmenu", "false");

4- All done. Export the movie clip in .swf  or .exe format and check with the file created.

Customize Context Menu in Flash:
                This method is valid for all type of versions i.e. swf,exe and also if you embed it in html page. You can also add more buttons and navigation by this method.

1- Open up Macromedia Flash and create a new file.
2- Select 1st frame from any layer. Better to make a separate layer for actions.
3- While the frame is still selected open up the Actions Panel (F9) and write the actions as follows:

function doNothing(){}
function gotoSite(){
                getURL("http:// learntoflash.blogspot.com/")
}
custom_menu = new ContextMenu();
custom_menu.hideBuiltInItems();
menu1 = new ContextMenuItem("Website Name", doNothing, false, false, true);
menu2 = new ContextMenuItem("Visit My Site", gotoSite, false, true, true);
custom_menu.customItems.push(menu1);
custom_menu.customItems.push(menu2);
_root.menu = custom_menu;

4- All done. Export the movie clip in .swf  or .exe format and check with the file created.

Description:
//First we create two functions one which will not do anything and other will have a link
function doNothing(){}
function gotoSite(){
                getURL("http:// learntoflash.blogspot.com/")
}
//Then we replace the menu with a custom menu
custom_menu = new ContextMenu();
//This will hide the built in items
custom_menu.hideBuiltInItems();
//This will add custom buttons to the menu
//This button will not do anything
menu1 = new ContextMenuItem("Website Name", doNothing, false, false, true);
//This button contains a link defined in gotoSite function
menu2 = new ContextMenuItem("Visit My Site", gotoSite, false, true, true);
custom_menu.customItems.push(menu1);
custom_menu.customItems.push(menu2);
_root.menu = custom_menu;

1 comment:

Please use sensible language.....!