You have found one reason not to use resultFormat="object". That result format causes flex to convert your result data, which is xml, into a tree of dynamic objects. You have no control over this process(, and it has some issues, particularly that values that look like numbers are converted to numbers) and it is even hard to predict. It is also hard to debug, though you can use ObjUtil.toString() to see the contents.
What is happening in your case is the "images" node becomes an object containing an Array or "image" nodes. So this expression: result.images.image returns an Array, which you can directly wrap in an ArrayCollection. I would not expect the direct assignment to work like you show it, and doing it that way hides what is really happening. This is more clear: var aResult:Array = ResultEvent( data ).result.images.image; trace(aResult.length); //is this what you expect var acImages:ArrayCollection = new ArrayCollection(aResult); Since an Array is an object, Josh's suggestion to use a for..in loop would work also. I advise using resultFormat="e4x". This leaves your result data as XML, so you can do: var xmlResult:XML = XML(ResultEvent( data ).result); trace(xmlResult.toXMLSTring()); //you will see your xml, unchanged. Now, you can use the xml directly, or use XMLList, or XMLListCollection, or combinations of the three. Or, if you want, you can convert your xml, or parts thereof, into ArrayCollections. Tracy ________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of sdl1326 Sent: Thursday, July 10, 2008 12:16 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Putting returned xml data into ArrayCollection using Cairngorm framwork (Command Class/Delegate Class/IResponder) Here's a sample xml that's getting loaded in via http service: <images duration="3000" effect="Fade" startDelay="2000"> <image name="image.jpg" url="http://www.cnn.com <http://www.cnn.com> "/> <image name="image1.jpg" url="http://www.usatoday.com <http://www.usatoday.com> " /> <image name="image2.jpg" url="http://www.msnbc.com <http://www.msnbc.com> " /> <image name="image3.jpg" url="http://www.digg.com <http://www.digg.com> " /> <image name="image4.jpg" url="http://www.google.com <http://www.google.com> " /> </images> If I change the code in the result handler to: var ac:ArrayCollection = ResultEvent( data ).result.images.image Then I have no issues putting it directly into an array collection. It's only when I remove the (.image) and have the following: var ac:ArrayCollection = ResultEvent( data ).result.images Is when I get the coercion error. Is there any reason why I shouldn't continue to put the data in an array collection via the 1st method? TIA --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , "Josh McDonald" <[EMAIL PROTECTED]> wrote: > > You're getting an ObjectProxy because you're using the "object" result > format. To convert to ArrayCollection: > > var myArray:Array = []; > for each (var img:* in result.images) > { > myArray.pish(img); > } > > myCollection = new ArrayCollection(myArray); > > -Josh > > On Thu, Jul 10, 2008 at 1:31 PM, sdl1326 <[EMAIL PROTECTED]> wrote: > > > Thanks for the assistance. > > > > I have left the resultformat blank (feel free to share why I shouldn't > > do this as I am always looking for best practices/advice). However,in > > previous projects, I have taken the return data from an http service > > and immediately put it in an arraycollection in the resulthandler. I > > just assumed the same could be done here when using Cairngorm, but > > apparently something isn't correct. I tried your suggestion below and > > am still receiving an error: > > > > TypeError: Error #1034: Type Coercion failed: cannot convert > > mx.utils::[EMAIL PROTECTED] to Array. > > > > Thanks in advance. > > > > > > > > -- > "Therefore, send not to know For whom the bell tolls. It tolls for thee." > > :: Josh 'G-Funk' McDonald > :: 0437 221 380 :: [EMAIL PROTECTED] >