populate list and combobox from xml
Hi all,
first time here so apologies for any mistakes ....
I am playing around with flex 2 and PHP. I have one page with a list box and a combo box on seperate panels. I am trying to populate both of these using a PHP backend which generates XML. The XML generation works beautifully as does the list box. My problem is that the combobox does not get populated, all i can see when running the app is [object Object] in the combobox !!!. the number of [object Object] match the number of items that are in the list box. I am sure it's a silly mistake on my part but being new to this I am not sure how to solve it. I have searched Google all day without success. Most of the examples hard code the array and if they do not, they use list boxes which is not what I am after. Perhaps there is no solution ....
Below is the mxml code.
Thanks in advance for any assistance you can provide.
Regards
Smakwam
/************************************************** *******
code start
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
width="390" height="430"
creationComplete="bs.send();"
>
<mx:Script>
<![CDATA[
import mx.managers.CursorManager;
import mx.rpc.events.InvokeEvent;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.collections.ArrayCollection;
[Bindable]
private var bloggersCol:ArrayCollection;
[Bindable]
private var bloggersCol2:ArrayCollection;
// Gets called when HTTPService is invoked to
// request the XML.
private function bsInvokeHandler(event:InvokeEvent):void
{
// Display the busy cursor
CursorManager.setBusyCursor();
}
// Gets called when the XML is successfully loaded.
private function bsResultHandler(event:ResultEvent):void
{
// Save a reference to the list of bloggers
bloggersCol = event.result.root.restaurant_category;
//bloggersCol2 = event.result.root.restaurant_category.name;
// Hide the busy cursor
CursorManager.removeBusyCursor();
}
private function bsFaultHandler(event:FaultEvent):void
{
// There was an error in loading the XML
Alert.show (event.fault.message);
// Hide the busy cursor
CursorManager.removeBusyCursor();
}
]]>
</mx:Script>
<!-- Service to load in XML -->
<mx:HTTPService
id="bs"
url="http://localhost/phpxml3.php"
invoke="bsInvokeHandler(event);"
result="bsResultHandler(event);"
fault="bsFaultHandler(event);"
/>
<mx:Panel title="Bloggers we love!" width="100%">
<mx:List
id="bloggersList" width="100%" rowCount="4"
dataProvider="{bloggersCol}"
labelField="name"
/>
<mx:ControlBar horizontalAlign="center">
<mx:Button
label="Add a blogger!"
click="bloggersCol.addItem({name:'Pete-Barr Watson', url:'http://petebarrwatson.com/'});"
/>
</mx:ControlBar>
</mx:Panel>
<!--<mx:ArrayCollection id="stateAC" source="{bloggersCol}"/> -->
<mx:Panel width="318" height="129" layout="absolute" title="Combo Box">
<mx:ComboBox x="10" y="10" width="278" id="cuisine" dataProvider="{bloggersCol}" >
</mx:ComboBox>
</mx:Panel>
</mx:Application>
/************************************************** ***
|