问题
What's the difference between array and arraycollection?
回答1:
First, the ArrayCollection is designed for the Flex framework. It acts like a Proxy
for a given Array
instance. This means it can listen for modifications made to the source Array
and update it self when this happens. It also contains a subset of additional methods required specifically by the framework (have a look at the IList implementation for instance).
回答2:
One important difference is that ArrayCollection
raises events whenever it is modified. This allows you to do data binding on it more effectively than you could do on an Array
.
回答3:
An ArrayCollection is a wrapper for an Array that lets it be used by GUI elements. Iterating through them is a bit tricky however, see here: http://npcomplete.weebly.com/1/post/2009/10/for-loops-in-actionscript.html
来源:https://stackoverflow.com/questions/2308730/difference-between-array-and-arraycollectionflex