3 Replies Latest reply on Aug 12, 2008 8:25 AM by ericbelair

    Context menus with sub menus

      I'm newbie in Flex, i try to do a Context menu with sub menus but i can't only i can do simple context menu, any can help me to do that?

      This is my code:
      I need that the open of the menu will be directly
      <?xml version="1.0"?>
      <!-- menus/SimpleMenuControl.mxml -->
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">

      // Import the Menu control.
      import mx.controls.Menu;

      import flash.ui.ContextMenu;
      import flash.ui.ContextMenuBuiltInItems;
      import flash.events.ContextMenuEvent;
      private var fsCM:ContextMenu;
      private var fs:ContextMenuItem;
      // Create and display the Menu control.
      private function init():void {
      fsCM = new ContextMenu();
      fs = new ContextMenuItem("Context");
      fs.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, Sns);
      this.contextMenu = fsCM;

      private function Sns(event:ContextMenuEvent):void{
      var myMenu:Menu = Menu.createMenu(null, myMenuData, false);
      myMenu.show(10, 10);

      <!-- Define the menu data. -->
      <mx:XML format="e4x" id="myMenuData">
      <menuitem label="MenuItem A" >
      <menuitem label="SubMenuItem A-1" enabled="false"/>
      <menuitem label="SubMenuItem A-2"/>
      <menuitem label="MenuItem B" type="check" toggled="true"/>
      <menuitem label="MenuItem C" type="check" toggled="false"/>
      <menuitem type="separator"/>
      <menuitem label="MenuItem D" >
      <menuitem label="SubMenuItem D-1" type="radio"
      <menuitem label="SubMenuItem D-2" type="radio"
      groupName="one" toggled="true"/>
      <menuitem label="SubMenuItem D-3" type="radio"

      <!-- Define a Button control to open the menu -->
      <mx:Button id="myButton1"
      label="Open Menu"
      <mx:LinkButton id="myButton" click="init()" label="LinkButton"/>