ArrayCollection versus vector objects in FLEX

Can someone tell me the applicable differences between ArrayCollection and Vector in flex? I am not sure if I should use one over the other. I saw that Vector is type safe and it makes me feel better, but are there any flaws?

public var ac:ArrayCollection = new ArrayCollection(); 

against

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

Thanks.

+6
flex
source share
4 answers

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

the rule

  • If you don't need data / event binding notifications, use Array

and

  • If all elements of the array are of the same type (and you want strong printing), use Vector.
+6
source share

I was looking for a way to convert from a vector to an arraycollection, so I can use it as a datapath, 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 a vector class, and it provides all the functions I need. At the moment, he has not created a performance benchmark, but I still think it is faster than an array. Collections.

+5
source share

Vector does not support data binding. This is the main difference that usually affects Flex developers.

+4
source share

The vector is legal only for Flash Player 10. From the documentation: "Runtime Versions: Flash Player 10, AIR 1.5, Flash Lite 4".

+1
source share

All Articles