Reputation: 1473
I need to initialize an array using direct initializing (ActionScript 3). Like this:
private var aa: Array;
function init() {
aa = [0x0050, 0x00ff, 0xff22];
}
I guess aa will contain array of numbers of any type that compiler wants. But I need them to be type of "int". How should I tell that for compiler?
Upvotes: 0
Views: 61
Reputation: 3230
The Array
class will not only contain any number type, it will contain any combination of types like
aa = ['apple', new MovieClip (), 123, 22.55]
Use the built-in Vector
class which is a typed Array
essentially. You can read more at the official page.
var v:Vector.<int> = new Vector.<int> ();
Upvotes: 2
Reputation: 1857
Array cannot be typed. You can use Vector instead of Array. This will be looks like:
private var aa:Vector.<int>;
function init():void {
aa = new <int>[0x0050, 0x00ff, 0xff22];
}
Upvotes: 1