0 Replies Latest reply on Feb 28, 2007 4:15 AM by Mark_TheWebGuru

    Menubar Events

    Mark_TheWebGuru
      Hi, I'm new to Flex so can anybody help me out with menu building.

      Problem: I can change viewStacks by itemClicks on the menuitems, however, my menu structure has only only menuitem for the home and logout buttons where the itemClick event doesn't work. Top level menus only have the click event which only passes the mouseEvent, not the menuEvent like in the itemClick. How can I get events to change viewStacks for my home and logout buttons

      My Code


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns="*" layout="absolute" pageTitle="POL Demo" creationComplete="initCollections();" >

      <mx:Script>
      <![CDATA[
      import mx.events.MenuEvent;
      import mx.controls.Alert;
      import mx.collections.*;

      [Bindable]
      public var menuBarCollection:XMLListCollection;

      private var menubarXML:XMLList =
      <>
      <menuitem label="Home" data="0" />
      <menuitem label="Transactions" data="top">
      <menuitem label="New Transaction" data="1"/>
      <menuitem label="Transaction Manager" data="4"/>
      </menuitem>
      <menuitem label="Reports" data="top">
      <menuitem label="X-Report" data="2"/>
      <menuitem label="Z-Report" data="3"/>
      </menuitem>
      <menuitem label="Maintenance" data="top">
      <menuitem label="Buyer's Maintenance" data="5"/>
      <menuitem label="PLU Maintenance" data="6"/>
      </menuitem>
      <menuitem label="Options" data="top">
      <menuitem label="Change Password" data="7"/>
      </menuitem>
      <menuitem label="Log Out" data="8"/>
      </>;

      private function initCollections():void {
      menuBarCollection = new XMLListCollection(menubarXML);
      }

      private function menuHandlerItemClick(oEvent:MenuEvent):void {
      storeViews.selectedIndex = oEvent.item.@data;
      }
      ]]>
      </mx:Script>
      <mx:Style source="main.css"/>

      <mx:VBox height="100%" width="100%">

      <mx:MenuBar id="mainMenuBar" labelField="@label" itemClick="menuHandlerItemClick(event);" dataProvider="{menuBarCollection}" styleName="storeControlBar">
      </mx:MenuBar>

      <mx:ViewStack id="storeViews" width="100%" height="100%" creationPolicy="all">
      <Menu_01_Home id="viewHome" label="Home"
      showEffect="WipeDown" hideEffect="WipeUp"
      />
      <Menu_02_NewTxn id="viewNewTxn" label="New Transaction"
      showEffect="WipeDown" hideEffect="WipeUp"
      />
      <Menu_03_XReport id="viewXReport" label="X-Report"
      showEffect="WipeDown" hideEffect="WipeUp"
      />
      <Menu_04_ZReport id="viewYReport" label="Z-Report"
      showEffect="WipeDown" hideEffect="WipeUp"
      />
      <Menu_05_TxnManager id="viewTxnManager" label="Transaction Manager"
      showEffect="WipeDown" hideEffect="WipeUp"
      />
      <Menu_06_MaintainBuyers id="viewMaintainBuyers" label="Buyers Maintenance"
      showEffect="WipeDown" hideEffect="WipeUp"
      />
      <Menu_07_MaintainPLU id="viewMaintainPLU" label="PLU Maintenance"
      showEffect="WipeDown" hideEffect="WipeUp"
      />
      <Menu_08_ChangePassword id="viewChangePassword" label="Change Password"
      showEffect="WipeDown" hideEffect="WipeUp"
      />
      <Menu_09_LogOut id="viewLogOut" label="Log Out"
      showEffect="WipeDown" hideEffect="WipeUp"
      />
      </mx:ViewStack>

      </mx:VBox>

      </mx:Application>


      Thanks in advance