Wednesday, November 19, 2008

Vectors! Typed arrays come to Actionscript 3

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

No comments: