redconservatory
redconservatory

Reputation: 21924

How to pass a class as a variable?

Is there a way to pass a Class as a variable in Actionscript 3.0?

For example:

private var myType:* // not sure how to pass, it's a class which implements an interface

myType = ClassA; // myType is now ClassA which extends Sprite;
myType = ClassB; // myType is now ClassB which extends Sprite;

Upvotes: 0

Views: 157

Answers (1)

Florian F
Florian F

Reputation: 8875

private var myType:Class = ClassA
var o:* = new myType(); 

o is now an instance of ClassA

Upvotes: 2

Related Questions