Contextual Menu with Link


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. import flash.display.Sprite;
  2. import flash.ui.ContextMenu;
  3. import flash.ui.ContextMenuItem;
  4. import flash.events.ContextMenuEvent;
  5. import flash.net.navigateToURL;
  6. import flash.net.URLRequest;
  7.  
  8. var menuItemLabel:String = "©2009 Foo Co.";
  9. var url:String = "http://www.foo.com";
  10. var cm:ContextMenu;
  11.  
  12.  
  13. cm = new ContextMenu();
  14. cm.hideBuiltInItems();
  15. var cmi:ContextMenuItem = new ContextMenuItem(menuItemLabel);
  16. cmi.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, menuItemSelected);
  17. cm.customItems.push(cmi);
  18. this.contextMenu = cm;
  19.  
  20.  
  21. function menuItemSelected(evt:ContextMenuEvent):void {
  22. var req:URLRequest = new URLRequest(url);
  23. navigateToURL(req, '_blank');
  24. }

URL: http://snipplr.com/favorites/Bonky/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.