views:

469

answers:

2

Hi,

Can any one Explain the Difference between the Array and ArrayCollection in Flex?

Thanks, Ravi

+2  A: 

As per the liveDocs

The ArrayCollection class is a wrapper class that exposes an Array as a collection that can be accessed and manipulated using the methods and properties of the ICollectionView or IList interfaces. Operations on a ArrayCollection instance modify the data source; for example, if you use the removeItemAt() method on an ArrayCollection, you remove the item from the underlying Array.

So really they're the same, but one has more properties and methods.

invertedSpear
I upvoted your answer, but technically they're not precisely the same, and it's a teensy bit misleading to imply that one is just a superset of the other. One of the ArrayCollection's properties (source) is the Array itself, and methods like push() that work on Arrays will not work on ArrayCollections, etc.
Robusto
One of the big differences between the two is that events and data binding work with ArrayCollection, but might not work properly with Array.
WayneH
Both good points, and knowing that the source of an ArrayCollection is an Array is pretty vital knowledge. Sure you don't have push, but you have addItem methods which are similar and can even be better.
invertedSpear
+1  A: 

The ArrayCollection class is a wrapper class that exposes an Array as a collection that can be accessed and manipulated using the methods and properties of the ICollectionView or IList interfaces.

The Array class lets you access and manipulate arrays. Array indices are zero-based, which means that the first element in the array is [0], the second element is [1], and so on.

Todd Moses