There are many great things about flex, and the flash 9 player, and actionscript 3…
I’m not brand new to flash, or flash development, i’ve never done anything truly amazing with it, but i’ve done what had to be done… it was always a pain… i’m so glad that flex 2.0 has released, i knew it would eventually get to this, and i can’t wait for it to just keep getting better…
A great tool that makes the web even more look like a true desktop application is the use of the
First things first,
1. Make your Script tag
2. import Classes
3. Create vars
4. Create 2 function —-One will be called when the menu item is clicked —-One will be called on the load of the app.
5. Create Your
1.
==================
<mx:Script>
<![CDATA[
]]>
</mx:Script>
2. FROM WITHIN YOUR SCRIPT TAG, IMPORT CLASSES
==================
import mx.events.MenuEvent;
import mx.controls.Alert;
import mx.collections.*;
3. CREATE VARS
==================
[Bindable]
public var menuBarCollection:XMLListCollection;
private var menubarXML:XMLList =
<>
<menuitem label=“File”>
<menuitem label=“Login” data=“mnuLogin”/>
<menuitem label=“Exit” data=“mnuExit”/>
</menuitem>
</>
4. Create 2 function
==================
private function menuHandler(event:MenuEvent):void {
Alert.show(“Label: “ + event.item.@label + “\n” + “Data: “ + event.item.@data + “\n”, “Clicked menu item”);
}
private function setUp():void{
menuBarCollection = new XMLListCollection(menubarXML);
}
5. Create Your MenuBar and Bind it
==================
<mx:MenuBar
labelField=“@label”
itemClick=“menuHandler(event);”
dataProvider=“{menuBarCollection}”
/>
I worked on trying to get the xml to import from a cfc last night for about 4 hours… it really bites when there is no book for some of the stuff you want to do… so you figure it out, it takes you forever, then other people act like it’s soooo easy to do, because time goes on, people write about it, people learn more, and the community grows… i’m glad i can be a part of it, and for some reason i like the learning other things that arent written about, it keeps me alive and interested.
i’ll write later about importing the xml from a cfc file.
Popularity: 8% [?]




3 users commented in " Using a MenuBar in flex 2.0 – Step 1 "
Follow-up comment rss or Leave a TrackbackHi, I’m trying to put icons in all menu items, but no success.
Do you know how can I do this?
With iconField only the root items seams to work.
Thanks
unfortunately i’ve never tried to put icons in the menu sorry.
Thanks a bunch for this brief tutorial! I was about to pull my hair out trying to figure out how to get this stupid menu bar set up.
A note for others reading this: Beware copying and pasting the XML from here into Flex. It converts the double quotes into something that looks like a double quote but doesn’t seem to want to be recognized in valid XML.
Leave A Reply