0 Replies Latest reply on Oct 11, 2006 2:27 AM by MarcoBazza

    Menu problem...

    MarcoBazza
      I'd like to create a Menu that still always visible, but I can't find how to do that.
      I read in the documentation this note:
      "If you create a Menu object by using the Menu.createMenu() method, the Menu is removed from the display list automatically when it is closed. To prevent this default behavior, you can listen for the menuHide event and call preventDefault() on the event object."

      I wrote this code, but the menu hides when the I click outside its.

      <?xml version="1.0"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      creationComplete="createAndShow()">
      <mx:Script>
      <![CDATA[
      import mx.controls.Alert;
      import flash.profiler.showRedrawRegions;
      import mx.events.MenuEvent;
      // Import the Menu control.
      import mx.controls.Menu;
      // Create and display the Menu control.
      private function createAndShow():void {
      // The third parameter sets the showRoot property to false.
      // You must set this property in the createMenu method, not later.
      var myMenu:Menu = Menu.createMenu(null, myMenuData, false);
      myMenu.labelField="@label";
      myMenu.iconField ="@icon";
      myMenu.addEventListener("menuHide",notHide);
      myMenu.show();
      }

      private function notHide(event:MenuEvent):void{
      event.preventDefault();
      }

      ]]>
      </mx:Script>

      <!-- Define the menu data. -->
      <mx:XML format="e4x" id="myMenuData">
      <menu>
      <menuitem label="Newsletter" icon="@Embed(source='images/wizard.png')" />
      <menuitem label="Sondaggi"/>
      <menuitem label="Statistiche"/>
      <menuitem type="separator"/>
      <menuitem label="Documenti"/>
      <menuitem label="Revistioni in corso"/>
      <menuitem label="Classificazioni" >
      <menuitem label="Tipologie"/>
      <menuitem label="Rilevanze"/>
      <menuitem label="Categorie"/>
      <menuitem label="Argomenti"/>
      <menuitem label="Sezioni"/>
      </menuitem>
      <menuitem type="separator"/>
      <menuitem label="Diritti di accesso"/>
      </menu>
      </mx:XML>

      <mx:VBox id="vbox">
      <!-- Define a Button control to open the menu -->
      <mx:Button id="myButton" label="Open Menu" click="createAndShow()"/>
      </mx:VBox>
      </mx:Application>

      Where is the problem ?