ArrayCollection versus Vector Objects in FLEX

梦想的初衷 提交于 2020-01-02 03:51:06

问题


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:


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.



回答2:


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.




回答3:


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




回答4:


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



来源:https://stackoverflow.com/questions/2672096/arraycollection-versus-vector-objects-in-flex

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!