Typed Arrays in AS3

In Mark Anders workshop at FlashBelt on Friday he introduced a new concept that I hadn’t used yet in ActionScript 3.0. Typed Arrays. In other languages you can specify that the elements of an array must be of a single type. In ActionScript you can’t do this. However, the Flex MXML compiler has a new metadata tag you can use to perform type checking on array elements. To use it you simply put the metadata tag right before your property definition:

[as][ArrayElementType(“Number”)]
public var numlist:Array;[/as]

Leave a Reply

Your email address will not be published. Required fields are marked *