开发者

Call library movieclips from an array of strings

I have an array of strings. Each string is a name of a class. How can I开发者_运维问答 call the library item with the class name that corresponds to the string in the array?

Thanks in advance


You can use the function getDefinitionByName, found in the package flash.utils.

Usually the code will look something like this:

var oClass:Class = getDefinitionByName("<name of your class>") as Class;
var instance:Object = new oClass();

You can also cast instance to a type of your choice:

var myType:SomeType = SomeType(instance);

See this link for reference.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜