As I suspected, you are not using xml: "I haven't set the resultformat of my httpservice, its using the default format."
The default resultFormat is to have Flex convert your XML into a nested dynamic object structure. This converts XMLLists into arrays, among other things. Generally this is bad. There is no benefit to a nested dynamic structure over XML and in fact, there are many reasons to use XML, e4x expressions being chief among those reasons. Your current situation is actually the worst of both worlds: you lose the e4x functionality and suffer from the performance hits of non-strongly-typed data access. The only reason to stay on this course is laziness. If you absolutely insist, I will tell you how to get a ArrayCollection out of the mess you have, but it would be a mistake. Two better options are: * Use XMLListCollection * Use e4x and convert your XMLList into an ArrayCollection of strongly typed data objects. This is a manual process of looping over the XMLList and building each object and then adding it to the ArrayCollection Tracy ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Nayan Savla Sent: Monday, March 03, 2008 7:11 PM To: [email protected] Subject: Re: [flexcoders] extracting items from array collection getItemAt doesn't work the url parameter for the httpService is a XML file so yes, var bigCollection:ArrayCollection = data.result.myBigList as ArrayCollection; //I am reading an xml file. this is true. I haven't set the resultformat of my httpservice, its using the default format. Also in the debugger i see that the variable bigCollection stores the xml file as a object list and as i mentioned i can easily extract the array from this using, var smallCollection:Array = bigCollection.toArray().slice(0,10); //this works just fine. the data in this array is as expected, What i don't understand is why i can't convert it into an ArrayCollection. Nayan On Mon, Mar 3, 2008 at 3:39 PM, Tracy Spratt <[EMAIL PROTECTED] <mailto:tspratt%40lariatinc.com> > wrote: > > > > > > > > > > Have you verified this line below? It raises doubts: > > > var bigCollection:ArrayCollection = data.result.myBigList as > ArrayCollection; //I am reading an xml file. > > > > First, XML will only yield an XMLList and you cannot cast an XMLList to an > ArrayCollection. > > > > I suspect you may not have xml as you think, but instead a nested object > structure. It depends on how you are getting your data. If that is so, it > is not a good way to do it. Have you set your resultFormat="e4x"? > > > > If you are getting XML from the server, why not use XMLListCollection? > > > > If you do not want to use that, you should convert your XMLList into an > ArrayCollection of strongly typed data objects. This is a manual process of > looping over the XMLList and building each object and then adding it to the > AC. > > > > Tracy > > > > ________________________________ > > > From: [email protected] <mailto:flexcoders%40yahoogroups.com> [mailto:[email protected] <mailto:flexcoders%40yahoogroups.com> ] On > Behalf Of Nayan Savla > Sent: Monday, March 03, 2008 4:00 PM > To: [email protected] <mailto:flexcoders%40yahoogroups.com> > Subject: [flexcoders] extracting items from array collection getItemAt > doesn't work > > > > > > > > Hi All, > > I am trying to get data from an ArrayCollection and i tried various > things without any luck. > > this is the code, > > var bigCollection:ArrayCollection = data.result.myBigList as > ArrayCollection; //I am reading an xml file. > > 1) var smallCollection:ArrayCollection = > bigCollection.getItemAt(0,10); //i believe this is the correct method > but doesn't work > > 2) var smallCollection:ArrayCollection = > bigCollection.toArray().slice(0,10) as ArrayCollection; //this returns > null > > 3) var smallCollection:Array = bigCollection.toArray().slice(0,10); > //this works just fine. > > any ideas why i can't just use the second statement, please ignore my > knowledge of flex if i am missing something fundamental. > > thanks > Nayan > >

