Reputation: 165
In many languages you can specify that an array is of a certain type. For instance, in Java you could write:
String[] arrayOfStrings;
However in ActionScript 3 it seems that you can only specify that an object is of type Array, for instance:
var myArray:Array;
Is there a way to specify what type of object an AS3 array will contain?
Upvotes: 2
Views: 1061
Reputation: 17347
You can use Vector.<String>
to store several objects of the given type in an array. Vector
is type-safe and is faster than Array
so in almost all cases (when it's up to you) you should use Vector
instead of Array
.
I also recommend reading this article about the various ways to construct a vector. The article is from 2010 (so many Flash Player improvements have been done since then) but much of it still applies and you can download Jackson's test source to run the performance test on the current player.
Upvotes: 7