2 Replies Latest reply on May 29, 2007 7:43 AM by Bayani Portier

    Handling menu event

    appu19
      Hi

      I am sending part of my application. when event.index==1 i want a new mxml application to be opened.

      for example if i have another changepassword.mxml file ,this should be opened and shown when menu event is clicked. I dont want to use viewstack to open another mxml.

      <?xml version="1.0"?>
      <!-- menus/EventListener.mxml -->
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      layout="absolute">
      <mx:Script>
      <![CDATA[
      import mx.controls.Menu;
      import mx.events.MenuEvent;

      private function createAndShow():void {
      var myMenu:Menu = Menu.createMenu(null, myMenuData, false);
      myMenu.labelField="@label"

      myMenu.addEventListener(MenuEvent.ITEM_CLICK,
      itemClickInfo);
      myMenu.show(225, 10);
      }

      private function itemClickInfo(event:MenuEvent):void {
      if(event.index==1){

      }

      }
      ]]>
      </mx:Script>
      <!-- The XML-based menu data provider. -->
      <mx:XML id="myMenuData">
      <xmlRoot>
      <menuitem label="MenuItem A" >
      <menuitem label="SubMenuItem A-1" enabled="false"/>
      <menuitem label="SubMenuItem A-2"/>
      </menuitem>
      <menuitem label="MenuItem B" type="check" toggled="true"/>
      <menuitem label="MenuItem C" type="check" toggled="false"/>
      </menuitem>
      </xmlRoot>
      </mx:XML>

      <mx:Button x="10" y="5"
      label="Open Menu"
      click="createAndShow();"/>
      <!-- Text area to display the event information -->

      </mx:Application>


      any solution is greatly appreciated.

      Thanks in advance.
        • 1. Re: Handling menu event
          JKohn99 Level 1
          You can use the navigateToUrl open a new Flex swf file. You would want to open it as a new window, assuming you want to preserve the application that you launch from.

          You seem to be thinking of mxml like web pages. That is really the wrong paradigm for Flex. A better design would be to make the changepassword panel visible
          when required.
          • 2. Re: Handling menu event
            Bayani Portier Level 1
            Mate,

            flex doesn't work that way. If something is as clustered in its views as a menu, then you must use the viewstack, rather than navigate to a new app entirely.

            The entire power of the architecture is to download, and then provide the user with an application like experience. You aren't dealing with lightweight HTML files.

            Here is a great article on a design approach. It uses Cairngorm as its architectural framework, but it kind of illustrates the approach JKohn99 and myself are talking about:

            http://www.digimmersion.com/support/Flex%20UI%20Design%20For%20Cairngorm.pdf