Mar 29, 2010

Flex 4: ArrayList vs ArrayCollection

ArrayList and ArrayCollection both can be used to store and manipulate list data. Both supports flex data binding which can drive the watching object to update itself on data change.
However the key difference between ArrayList and ArrayCollection is that ArrayCollection has additional logic to sort and filter the list data however ArrayList is created specifically to hold and manipulate data and still be bindable. Thus ArrayList is lighter version of ArrayCollection.
Note: ArrayList is added in Flex 4 thus it will not be availalble in previous versions of flex sdk.
Technorati Tags: ,

13 comments:

  1. Thanks for the explanation,

    I used to wonder witch one to choose and always thought them to be very similar. Now I can certainly make a better choice.

    ReplyDelete
  2. Thank you for clarifying !!

    ReplyDelete
  3. Thanks for making this clear to us.

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. Thanks for the post. But ArrayList is mx dataprovider that means it is added in Flex3 and not in Flex4.

    ReplyDelete
    Replies
    1. You are true. My focus, while writing, was not on the Flex versions, but on the differences between these two data structures.
      Thanks for mentioning anyways.

      Delete
  6. Also, ArrayList does not support cursors (e.g. createCursor), ArrayCollections do.

    ReplyDelete
    Replies
    1. Absolutely correct. Thanks for this info.

      Delete
  7. i wanna sort arraylist...thn wht shud i do for dat?

    ReplyDelete
    Replies
    1. You can't sort ArrayList. Do one thing, create an Array of your data. Sort on that Array and provide that Array as a source to your ArrayList. That should do it.

      Delete
  8. Thanks bro.....made our conception clear.... :)

    ReplyDelete

I love comments.