ActionScript 3 Optimizing Performance Vectors instead of Arrays


Flash Player 10 introduced the Vector.<*> generic list type that was faster than the Array. However, this is not entirely true. Only the following Vector types are faster than the Array counterparts, due to the way they are implemented in Flash Player.

  • Vector.<int> - Vector of 32-bit integers
  • Vector.<uint> - Vector of 32-bit unsigned integers
  • Vector.<Double> - Vector of 64-bit floats

In all other cases, using an Array will be more performant than using Vectors, for all operations (creation, manipulation, etc). However, if you wish to "strongly type" your code then you can use Vectors despite the slowdown. FlashDevelop has a syntax that enables code completion drop-downs to work even for Arrays, by using /*ObjectType*/Array.

var wheels:Vector.<Wheel> // strongly typed, but slow

var wheels:/*Wheel*/Array // weakly typed, but faster