Welcome!

ColdFusion Authors: Maureen O'Gara, Hovhannes Avoyan, Yakov Fain, Pat Romanski, Liz McMillan

Related Topics: ColdFusion

ColdFusion: Article

My First Flex Application

For this article I used Flex 2 beta3. Since then Flex 2 has been released so you should download that

Change the label to Show Details.

Figure 28

Click on the Panel again. Under Flex Properties, locate the Layout area. Change the Layout of the Panel to Width = 400, Height = 200.

Figure 29

Locate the Add New State icon in the upper right corner. Click on it to Add a New State.

Figure 30

We'll call this state details. Type details in the Name field and press OK.

Figure 31

Change the Width on the details Panel to 500 and the Height to 400. Select the Button and delete it. Drag a new button component to the BarControl and change the label to Hide Details.

Figure 32

Click the Base State on the upper-right-hand corner. Click the button. In Flex Properties, under the Common area, Type currentState='details' next to On click to make the base state "transform" or turn into the details state.

Figure 33

Click the details State on the upper-right-hand corner. Click the button. In Flex Properties, under the General area, Type currentState=' ' next to Click to make the details state "transform" or turn back into the base state.

Figure 34

Click on the Base state and select the Source tab to display the source code for the Base state.

Figure 35

Flex uses MXML markup language. Your code should look similar to this.

Next, we will add some data to our panels using the HTTPService command to read an XML file located currently in your application bin folder. Copy the Catalog.xml file to your application's bin folder.

Figure 36

We're going to add three lines to our source code. The first line will define the service we'll be using.

Figure 37

Right above the states tags type:

<mx:HTTPService id="srv" url="catalog.xml"/>.

Figure 38

Next, define the container that will hold the data we're retrieving. Right before the mx:ControlBar tag type:

<mx:DataGrid width="100%" height="100%"dataProvider="{srv.result.catalog.product}"/>

Figure 39

Get the data when the application starts up by adding the following line to the mx:Application tag:

creationComplete="srv.send()"

Now save and run your application.

Figure 40

Figure 41

Press the Show Details Button.

Figure 42

Here the Details are displayed. Press the Hide Details button to return to the previous screen.

Figure 43

Congratulations! You've just built your first Flex application.

Click here for source code!

More Stories By Mary McDonald

Mary McDonald has served the last four years as the Northern Indiana Adobe Users Group Manager (see www.ninmug.org), has attended many conferences including CFUNITED, MAX, MXNorth and TodCon. Out of her 16 years working as a software developer, Mary has worked the last 6 years with ColdFusion, SQL, Flash, and Flex and is a Certified 5.0 ColdFusion Developer. Mary's other interests include music, photography, traveling, dogs, and most recently Tai Chi.

Comments (3) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
George Lu 09/15/06 01:54:00 AM EDT

Thanks! That's what I want. The original code with 'srv.result.catalog.product' has error. But where does 'lastResult' come from?

>>> QUOTE:
-FYI-
DataGrid Syntax Error: For me to get the app to work, I needed to change the mx:DataGrid tag to

bigbadken 09/06/06 11:06:57 AM EDT

Catalog.xml: It's located in the samples folder under the Flex Builder 2 Plug-in folder. For me, that was

C:\Program Files\Adobe\Flex Builder 2 Plug-in\Flex SDK 2\samples\flexstore\data\catalog.xml.

-FYI-
DataGrid Syntax Error: For me to get the app to work, I needed to change the mx:DataGrid tag to

<mx:DataGrid width="100%" height="100%" dataProvider="{srv.lastResult.catalog.product}"/>

Greg C 09/04/06 05:28:19 PM EDT

I can not find the Catalog.xml that I am suppose to copy to the BIN folder. The quote below says that it is currently in my Application folder.... nope... it is not... in fact I don't even have a bin folder. The walk through has be great until now when it refenced a file I can't find. Please send me the file... or let me know where I can download it, etc.

>>> QUOTE:
Next, we will add some data to our panels using the HTTPService command to read an XML file located currently in your application bin folder. Copy the Catalog.xml file to your application's bin folder.