开发者

How to pass a class as a variable?

开发者 https://www.devze.com 2023-02-09 13:55 出处:网络
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

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;


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

o is now an instance of ClassA

0

精彩评论

暂无评论...
验证码 换一张
取 消