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 it’s a fantastic addition, and i haven’t had a chance to look at the actionscript that it generates, but i know that i love it and it’s capabilities… i will soon be blogging on make the menu dynamic, and bringing the xml in from a query generated in coldfusion, but for now i’ll start rather simply… I can’t remember where i found this but it is a great thing!

View Example

Download Example

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 and Bind it

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.