Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ArrayCollection versus Vector Objects in FLEX

Tags:

apache-flex

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.

like image 319
Vetsin Avatar asked Apr 20 '10 02:04

Vetsin


2 Answers

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.
like image 67
keyle Avatar answered Nov 15 '22 10:11

keyle


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.

like image 44
andreiRS Avatar answered Nov 15 '22 09:11

andreiRS