Posted By

Bonky on 02/20/09


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Pingpongbal


Contextual Menu with Link


 / Published in: ActionScript 3
 

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

  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. }

Report this snippet  

You need to login to post a comment.