tags:

views:

455

answers:

4

Can anyone tell me the applicable differences between an ArrayCollection and a Vector in flex? I'm unsure if I should be using one over the other. I saw that Vector is type safe and that makes me feel better, but are there disadvantages?

public var ac:ArrayCollection = new ArrayCollection();

versus

public var vec:Vector.<String> = new Vector.<String>();

Thanks.

+1  A: 

Vector is only legal on Flash Player 10. From the documentation: "Runtime Versions: Flash Player 10, AIR 1.5, Flash Lite 4".

Sam Goldman
+1  A: 

Vector does not support Data Binding. That is the primary difference that usually impacts Flex developers.

James Ward
+1  A: 

Additionally, Vector is about 3 times faster than Array, which is about 18 times faster than ArrayCollection.

rule of thumb is

  • if you don't need data binding / events notifications, use Array

AND

  • if all elements in the array are of the same type (and you want strong typing), use Vector.
keyle
+1  A: 

I was searching for a way to convert from a vector to an arraycollection so I can use it as a dataprovider and I found this:

http://www.bealearts.co.uk/blog/2010/10/10/vectorcollection-class-to-allow-binding-to-an-as3-vector/comment-page-1/#comment-9486

David Beale created a wrapper over the vector class and it gives it all functionality that I need. At this moment he did not create a performance benchmark but I still think is faster then an arrayCollection.

RS