The Vector class is very similar to Array but is only supported by the Flash Player 10+
Static methods
staticinlinetypeReference<T>():Class<Vector<T>>
Get a run-time value referencing the Vector
class with concrete type parameters.
Normally in Haxe, for most of the types, type parameters are eliminated at run-time, so there is no way to check if a value is of a type with specific type parameters.
However, on the Flash target, the flash.Vector<T>
values carry type parameter
information at run-time all the type-checks (such as Std.isOfType
and Std.downcast
) on them
must be done using a Class<T>
value that also carries the type parameters. However,
Haxe syntax does not allow creating such values and this function exists to mitigate
this limitation.
It should be used as such:
var specificVectorType:Class<Vector<Int>> = Vector.typeReference();
trace(Std.isOfType(vec, specificVectorType));
or using the type-check syntax:
trace(Std.isOfType(vec, (Vector.typeReference() : Class<Vector<Int>>)));
It's also helpful when working with native Flash libraries, that receive Class instances:
new Signal((Vector.typeReference() : Class<Vector<Int>>));