Home / Tutorials / Navigation / Right Click Context Menu /

Flash Tutorials

Right Click Context Menu - The Actionscript

Posted by : PhilS on Aug 02, 2008

 

3.0/5

The actions in Frame 1 are as follows:

var myContextMenu = new ContextMenu();
myContextMenu.hideBuiltInItems();
var spin = new ContextMenuItem("Spin Spin Spin!!!", mySpin);
myContextMenu.customItems.push(spin);
function mySpin() {
    webwasp.gotoAndPlay(2);
}
webwasp.menu = myContextMenu;

ActionScript Explained:

var myContextMenu = new ContextMenu(); This creates a new object from the ContextMenu class.

myContextMenu.hideBuiltInItems(); This hides the standard items that are in the Flash context menu

var spin = new ContextMenuItem("Spin Spin Spin!!!", mySpin); Creates the text label that will be visible in the new Context menu and links this item to the function: mySpin

myContextMenu.customItems.push(spin); Places the new item created in the variable spin into the context menu

function mySpin() 
{
  webwasp.gotoAndPlay(2); 
}

When you click on the Context menu item, anything listed in this function will be executed.

webwasp.menu = myContextMenu; Associates all of the above with the movie clip called webwasp.

no comment

Add comment

Please login to post comments.