如何将类作为变量传递?

时间:2011-02-10 14:50:18

标签: actionscript-3

有没有办法在ActionScript 3.0中将Class作为变量传递?

例如:

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;

1 个答案:

答案 0 :(得分:2)

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

o现在是ClassA的实例