0

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?

2 Answers 2

2

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> ();
Sign up to request clarification or add additional context in comments.

Comments

1

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];
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.