views:

110

answers:

4

Dear friends,

While making my choice b/n Array and Arraycollection I get confused why whould I use one and why not another. I have read the theory in langref but apart from that is there some general advantages/disadvantages of one over the another that you have learned from your experience.

Thanks in advance.

+4  A: 

An ArrayCollection is a wrapper over an Array. It provides sorting and filtering functionality which can be used for display purposes without affecting the underlying data.

By using a collection class, it is also easy to switch between data formats, such as to an XMLListCollection without having to re-write all of your sorting and filtering code. [at least in theory].

www.Flextras.com
A: 

In my experience, ArrayCollection is easier to work with, especially if you are modifying your array, but that comes at the expense of performance and overhead. If performance is an issue I'd consider using and Array.

Wade Mueller
A: 

This explains the differences. Ultimately the ArrayCollection is helpful, but really slow for even simple actions like iterating over the list. If you are working with a view then use an ArrayCollection. But to pass data around your application, stick with an Array.

jonbcampos
A: 

As a simplified rule of thumb, in Flex 3 use Array for read-only data providers and ArrayCollection for data providers that can be modified at the run-time.

In Flex 4 Spark data eager components such as List or DataGroup expect data providers to be typed as IList, so no more Array typed collections for data providers in any case.

JabbyPanda