This sample shows how to add a menu to your context menu or the right click of your menu in Adobe AIR. AIR Uses the ContextMenu class to add menu to your mouse right click.

   import mx.controls.Alert;
   // call this function to create context menu in AIR and FLex
   private function createContextMenu():void
      var myContextMenu:ContextMenu = new ContextMenu();
     this.contextMenu = myContextMenu;       //add menu items

     var myMenuItem1:ContextMenuItem = new ContextMenuItem('Menu Item 1');
     var myMenuItem2:ContextMenuItem = new ContextMenuItem('Menu Item 2');

     myContextMenu.customItems = [myMenuItem1, myMenuItem2 ];

     //add event listeners to menu items
     myMenuItem1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, menuItemClick1);
     myMenuItem2.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, menuItemClick2);

    }     // listener functions for context menu items
       private function menuItemClick1(event:Event):void
        //Write here the code for on click of item 1'Menu Item 1 clicked');
       private function menuItemClick2(event:Event):void{
           //Write here the code for on click of item 2
 'Menu Item 2 clicked');


  1. Pingback: How to display a context menu from a fragment? | Free Tools Successful Bloggers Are Using

  2. Pingback: How to display a context menu from a fragment? | All Things Gadget

Leave a Reply

Your email address will not be published. Required fields are marked *




Theme by HermesThemes

Copyright © 2018 CoderzHeaven. All Rights Reserved

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.