Here's an example of one way of doing that.
Assuming you xml comes from a webservice or httpservice call and you want your
combobox dataprovider bound to a variable comboboxAC you could try the
following function onResult.
private function onResult( event:ResultEvent ):void{
// put xml into array
var returnedData:ArrayCollection = new ArrayCollection(ArrayUtil.toArray(
event.result ) );
// loop over result array and create a new object for
each xml item
for (var i:uint = 0;i<returnedData.length;i++){
// create object
var obj:Object = new Object();
obj.label=returnedData[i].name;
obj.data=returnedData[i].id;
// add item to combobox dataprovider
comboboxAC.addItem(obj);
}
}
T
________________________________
From: [email protected] [mailto:[email protected]] On Behalf
Of Matthew A. Wilson
Sent: Tuesday, 24 March 2009 8:12 a.m.
To: [email protected]
Subject: [flexcoders] Bind ComboBox to returning XML (HOW TO)
Need help with a combobox...
I have a combobox that I want to load from a database. The text will be a name,
and the value will be an integer.
That's it - pretty straightforward. Just can't seem to figure it out. The xml
will look like this:
<designers>
<designer id="1" name="Matt" />
<designer id="2" name="Ted" />
</designers>
Thanks so much in advance for your help!!!