# Right Click ContextMenu trouble

**URL:** <https://forum.kirupa.com/t/right-click-contextmenu-trouble/320661>\
**Category:** flash\
**Created:** [March 29, 2011, 4:53pm UTC](https://forum.kirupa.com/t/right-click-contextmenu-trouble/320661 "2011-03-29T16:53:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![RichGags](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/richgags/32/685_2.png) [@RichGags](https://forum.kirupa.com/u/RichGags)\
**Post date:** [March 29, 2011, 4:53pm UTC](https://forum.kirupa.com/t/right-click-contextmenu-trouble/320661/1 "2011-03-29T16:53:42Z")

</div>

I would like to add a custom right click menu to my site in a class. I have created a rightClick.as with …

```auto
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…

```auto

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.
