Right click code for Flash Action Script 3

Ever noticed how when you right-click a flash application you get a whole heap of options: ‘Zoom’, ‘Show all’, ‘Rewind’, etc… they’re not really necessary are they?

Add this code and magically they all disapear! With exception to settings and about – you can also add in two (or one or three, etc.) of your own menu options:

//right click code – table4.com
var rightClick:ContextMenu = new ContextMenu();

rightClick.hideBuiltInItems();
var rightClick1:ContextMenuItem = new ContextMenuItem(“YOUR TEXT”);
var rightClick2:ContextMenuItem = new ContextMenuItem(“MORE TEXT WITH LINK”);

rightClick2.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, rightClickUrl);
rightClick.customItems.push(rightClick1, rightClick2);

this.contextMenu = rightClick;
function rightClickUrl(e:ContextMenuEvent):void {
var url:String = “http://www.table4.com/”;
var request:URLRequest = new URLRequest(url);
navigateToURL(request, ‘_blank’);
}

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • MySpace
  • Reddit
  • TwitThis
  • Yahoo! Buzz
  • LinkedIn

Leave a comment