Wwwebber's Blog

Vectors! Typed arrays come to Actionscript 3

Posted in actionscript 3, flash player 10, vector example by wwwebber on November 20, 2008

Finally got my hands on CS4… one of the main new new perks of the Actionscript is the new Vector class (nothing to do with physics or vector graphics)…these are good old typed arrays in the style of C++ or Java.

Basics of the Syntax

//create a Vector and call it vec

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

now “vec” can only store ints! This allows for Type-safety in your code, and potentially performance gains.

to add an object to a vector just call .push()
//the next line adds the int ‘3’ to the vector
vec.push(3);

Much more info over at Senocular

Comments Off on Vectors! Typed arrays come to Actionscript 3