I would like to add a custom right click menu to my site in a class. I have created a rightClick.as with …
package {
import flash.display.Sprite;
import flash.ui.ContextMenu;
import flash.ui.ContextMenuItem;
import flash.events.ContextMenuEvent;
import flash.net.navigateToURL;
import flash.net.URLRequest;
public class rightClick extends Sprite
{
private var menuItemLabel:String = "© Test";
private var url:String = "http://www.test.com";
private var cm:ContextMenu;
public function rightClick()
{
cm = new ContextMenu();
cm.hideBuiltInItems();
var cmi:ContextMenuItem = new ContextMenuItem(menuItemLabel);
cmi.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, menuItemSelected);
cm.customItems.push(cmi);
this.contextMenu = cm;
}
private function menuItemSelected(evt:ContextMenuEvent):void
{
var req:URLRequest = new URLRequest(url);
navigateToURL(req, '_blank');
}
}
}
Now, from my main movie class… I would like to make sure the right click menu is displayed. How I call it from the main class which looks like this…
public class MainFile extends MovieClip
{
public const CHANGE_PAGE:String = "onChangePage";
private const SIDEBAR_LEFT_WIDTH:Number = 200;
etc..etc...
{
public function MainFile():void
{
this.addEventListener(Event.ADDED_TO_STAGE, stageAdded);
this.addEventListener(Event.REMOVED_FROM_STAGE, stageRemoved);
// should I put the right click call here? How would I call it?
}
Thanks.