6

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.

4 Answers 4

6

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.
Sign up to request clarification or add additional context in comments.

Comments

5

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.

Comments

4

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

Comments

1

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

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.