7

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

1

2 Answers 2

7

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.

Sign up to request clarification or add additional context in comments.

3 Comments

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.
One of the big differences between the two is that events and data binding work with ArrayCollection, but might not work properly with Array.
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.
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.