1 Reply Latest reply on May 9, 2007 4:19 PM by BLXWebMaster

    Menu

    appu19
      Hi

      i have a menu and menu items in it.. when menu item is selected anothere mxml application shoub opened ...

      For example i ahve menu in login.mxml... n when i click menu item"changepassword" , changepassword.mxml should be opened.

      Can u plss help me out..

      Thanks in advance
        • 1. Re: Menu
          BLXWebMaster Level 1
          You should try to provide a little more information as you post is vague. Are you using Viewstacks, States, do you want the window to open sperately? What are you using for your menus, a menu Bar? Do all your menus have sub-menus or are you trying to access top level information?

          Here is a quick sample using Menu Bar and View Stack, but would help if you post actual code to work with.
          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application
          xmlns:mx=" http://www.adobe.com/2006/mxml"
          xmlns="*"
          layout="absolute"
          width="100%"
          height="100%"
          creationComplete="initCollections();">

          <mx:Script>
          <![CDATA[
          import mx.collections.IViewCursor;
          import mx.collections.ArrayCollection;
          import mx.collections.*;
          import mx.events.*;
          import mx.controls.*;
          import mx.effects.easing.*;
          import mx.controls.menuClasses.MenuBarItem;
          import mx.collections.XMLListCollection;


          [Bindable]
          public var menuBarCollection:XMLListCollection;

          private var menubarXML:XMLList =
          <>
          <menuitem label="Home"/>

          <menuitem label="About Us" data="AboutUs">
          <menuitem label="About Us" data="AboutUs"/>
          <menuitem label="Change Password" data="ChangePassword"/>
          </menuitem>
          </>;

          // Event handler for the MenuBar control's itemClick event.
          private function menuHandler(event:MenuEvent):void {

          var viewString:String = event.item.@data;
          siteViews.selectedChild=this[viewString];
          }

          // Event handler to initialize the MenuBar control.
          private function initCollections():void {
          menuBarCollection = new XMLListCollection(menubarXML);
          }

          //Click event handler for the main button.
          // You can modify to use the Data Tag also and eliminate the case statement
          public function clickHandler():void {
          var selectedItem:String = barMenu.selectedIndex.toString();
          switch(selectedItem) {
          case "0": // Home
          siteViews.selectedChild=this['Home'];
          break;
          default:
          break;
          }
          }
          ]]>
          </mx:Script>

          <mx:MenuBar showRoot="true" id="barMenu" labelField="@label" click="clickHandler()" itemClick="menuHandler(event);" dataProvider="{menuBarCollection}" width="100%" borderColor="#c0c0c0" fillColors="[#8f8f8f, #c0c0c0]" fillAlphas="[1.0, 1.0]" color="#ffffff" fontSize="10" fontWeight="bold"/>

          <mx:ViewStack id="siteViews" width="100%" height="100%" creationPolicy="all">
          <!-- Put Your Components [MXML Files] Here -->
          <HomeView id="Home"/>
          <AboutUsView id="AboutUs"/>
          <ChangePasswordView id="ChangePassword"/>
          </mx:ViewStack>
          </mx:Application>