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:[EMAIL PROTECTED] On
Behalf Of Nayan Savla
Sent: Monday, March 03, 2008 4:00 PM
To: [email protected]
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

 

Reply via email to