Vector class is a strongly-typed array implementation in ActionScript 3.  There are lots of blog posts or Stackoverflow posts related Vector, I am simply aggregating a few I have found useful

1. How to instantiate a Vector type with values?

var vec:Vector.<Number> = new <Number> [1.0, 1.0];

(Credit: Stackoverflow.com)

2. What kind of performance advantage Vector has over Array?
Answer: A lot, and each iteration of Flash Player may have different merits. The latest result shows Vector has more than a 100% speed advantage over Array.
(Credit: ActionScript performance test for Array, Object, Vector literals and Array.push, Vector.push methods)

3. Any drawback of Vector?
Answer: One drawback I see so far is Vector has no AMF equivalent. If you don’t know what AMF is or would not use Vector to transfer data back and forth to server, then you don’t have to worry. Otherwise, a work-around would be translate Vector to Array or ArrayCollection at transport. This little overhead is minimal as it only occurs at transport. I would strongly recommend anyone use Vector as much as possible.

Another drawback of Vector would be that it is a primitive type like Array, therefore it lacks sophisticated events notifying change of a Vector. Though the latest Apache Flex 4.9 has VectorList and VectorCollection implementation, the implementation offers little or adversed performance advantage, and I would not advise using VectorList/VectorCollection just yet.

Advertisements