This is a common question. Given some XML, and asked to convert to an object, how do we know if a single item should be an array? We don't, so single items become straight objects instead of arrays and thus don't work well in array collections, which are collections of objects.
That's why if resultFormat="e4x" and you use XMLListCollection, we don't have to guess at the mapping. -Alex ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of pdenys Sent: Wednesday, March 14, 2007 4:51 AM To: [email protected] Subject: [flexcoders] Re: Combobox will not display (only) one item Thanks for your reply. That did not work as "state" is the repeating element not "states". If there are more than 1 "state" then this works fine. I don't understand why 1 element would give the ComboBox trouble. --- In [email protected] <mailto:flexcoders%40yahoogroups.com> , "Hilary Bridel" <[EMAIL PROTECTED]> wrote: > > Hi, > Try changing: > > myAC = event.result.states.state; > > to > > myAC = event.result.states; > > Hilary > > -- > > On 13 Mar 2007 19:36:50 -0700, pdenys <[EMAIL PROTECTED]> wrote: > > > > I have a simple example where my ComboBox has a dataProvider that is > > an ArrayCollection. This ArrayCollection is assigned to the results > > of an HTTPService that retrieves an xml file of US States. The XML > > file is just sitting on a local web server. > > > > Why is it that when there is only 1 entry (State) in my XML file, the > > ComboBox does not populate correctly (it is blank)? > > > > Here is my XML: > > -------------- > > <?xml version="1.0" encoding="utf-8"?> > > <states> > > > > <state> > > <label>MO</label> > > <data>Jefferson City</data> > > </state> > > > > </states> > > > > Here is my code: > > --------------- > > <?xml version="1.0"?> > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> "> > > > > <mx:HTTPService > > id="serviceTest" > > url="http://localhost:8080/states.xml <http://localhost:8080/states.xml> " > > result="resultHandler(event)" > > /> > > > > <mx:ComboBox id="cmbTest" labelField="label" width="300" > > dataProvider="{myAC}"/> > > <mx:TextArea width="292" id="txtTest1"/> > > <mx:TextArea width="290" id="txtTest2"/> > > <mx:Button label="Feed from file" width="285" id="btnFeed" > > click="serviceTest.send()"/> > > > > <mx:Script> > > <![CDATA[ > > import mx.collections.ArrayCollection; > > import mx.rpc.events.ResultEvent; > > > > [Bindable] > > public var myAC:ArrayCollection = new ArrayCollection(); > > public function resultHandler(event:ResultEvent):void > > { > > myAC = event.result.states.state; > > } > > ]]> > > </mx:Script> > > </mx:Application> > > > > > > > > > > -- > Hilary > > -- >

