Calendar
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Recent Entries
Come On In, Rails-The Water's Warm
Shan's Simple Examples: File uploads with Flex and ColdFusion
Recent Comments
Google Calendar API - Creating a new Calendar with ColdFusion
Steve Julian said: When and where are you going to post the finished CFC's ? Thanks
[more]
Three Phases of Programmer Development
Pat Branley said: I normally think of those phase 2 people as 'programmers' and the phase 3 people as 'developers'.
I...
[more]
New Job Title: Front End Engineer
Sean Corfield said: Well, there's always the excellent Fusion Authority Quarterly Journal...
[more]
Down To The Wire: HTTP Sniffers
Brian M said: I second the mention of the Charles Web Debugging Proxy that Tariq mentioned. It is fantastic. It s...
[more]
New Job Title: Front End Engineer
Patrick said: Heya Sean. Good point. I never understood how they did things over there at SysCon, and I understand...
[more]
Archives By Subject
Business of Software (4) [RSS]
ColdFusion (318) [RSS]
Conferences (6) [RSS]
Databases (87) [RSS]
Flex & Flash (109) [RSS]
Fusebox (87) [RSS]
General Development (29) [RSS]
Google (9) [RSS]
Hardware (5) [RSS]
JVM & Java (132) [RSS]
Linux (20) [RSS]
Miscellaneous (254) [RSS]
Performance (8) [RSS]
SeeFusion (36) [RSS]
Shan's Simple Examples (6) [RSS]
User Interface (3) [RSS]
Windows (5) [RSS]
Archives By Poster
Daryl Banttari (10)
Nat Papovich (29)
Patrick Quinn (36)
Shannon Hicks (22)
Steve Nelson (21)
Tyson Vanek (3)
Shan's Simple Examples: Using an XML datasource with mx:ComboBox
Over the weekend I was writing a simple little app, and came across something that should have been trivial, but turned out to throw me for a loop momentarily. I needed to drive some data from XML instead of my tried-and-true ColdFusion components, and I realized I'd never done it before. So, here's the example:
First off, you need to actually get the XML file using a HTTPService:
Looks simple enough, but to produce valid XML, I needed to have a root node around my other nodes:
<varieties>
<variety name="Standard"/>
<variety name="Angora"/>
<variety name="Satin"/>
<variety name="Rex"/>
<variety name="Texel"/>
<variety name="Satin Texel"/>
<variety name="Satin Rex"/>
<variety name="Satin Angora"/>
<variety name="Fuzzy"/>
<variety name="Fuzzy Angora"/>
<variety name="Fuzzy Hairless"/>
<variety name="Fuzzy Hairless Angora"/>
<variety name="Hairless"/>
</varieties>
Now, when I put this directly into a XMLList object, I got a ComboBox with one option... my entire XML packet. It took a few tries to realize that I needed to make the DataProvider only the "variety" nodes, and that was easy to do:
varietyXML = XMLList(e.result.variety);
}
So, for everyone who likes to see the whole picture, like me, here's the entire MXML code:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" initialize="init()">
<mx:HTTPService id="varietyService" url="varieties.xml" resultFormat="e4x" result="varietyResult(event)"/>
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
[Bindable] private var varietyXML:XMLList;
private function init():void {
varietyService.send();
}
private function varietyResult(e:ResultEvent):void {
varietyXML = XMLList(e.result.variety);
}
]]>
</mx:Script>
<mx:ComboBox id="variety" dataProvider="{varietyXML}" labelField="@name"/>
</mx:Application>


thanks!