Here is another example that's a lot less buggy and uses an MXLList,
XMLListCollection and a MenuBar. This is taken mostly from the example
listed in the help:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute"
     creationComplete="onComplete(event)">
     <mx:Script>
         <![CDATA[
             import mx.events.MenuEvent;
             import mx.events.FlexEvent;
             import mx.collections.*;

             [Bindable] public var menuBarCollection:XMLListCollection;

             public function onComplete(event:FlexEvent):void
             {
                 menuBarCollection = new XMLListCollection(myMenuData);
                 myMenuBar.x = 100;
                 myMenuBar.y = 100;
             }

             private function menuClickHandler(event:MenuEvent):void
             {
                 if(event.label == "Lock / Unlock")
                 {
                    
if(myMenuData..menuitem.(attribute("id")=="menuDown")[EMAIL PROTECTED] ==
false)
                     {
                        
myMenuData..menuitem.(attribute("id")=="menuDown")[EMAIL PROTECTED] = true;
                     }
                     else
                     {
                        
myMenuData..menuitem.(attribute("id")=="menuDown")[EMAIL PROTECTED] = false;
                     }
                 }
             }
         ]]>
     </mx:Script>
     <mx:XMLList id="myMenuData">
         <menu label="My Menu">
             <menuitem id="menuDrill" label="Drill =&gt;" >
                 <menuitem id="menuDown" label="Down" toggled="false"
enabled="true"/>
                 <menuitem id="menuUp" label="Up" toggled="false"
enabled="true"/>
             </menuitem>
             <menuitem type="separator"/>
             <menuitem label="Lock / Unlock" type="check"
toggled="false"/>
             <menuitem type="separator"/>
             <menuitem label="Reset Graph" toggled="false"/>
         </menu>
     </mx:XMLList>
     <mx:MenuBar id="myMenuBar" labelField="@label"
itemClick="menuClickHandler(event);" dataProvider="{menuBarCollection}"
/>
</mx:Application>


Reply via email to