简体   繁体   中英

How to transform name of FXG file into SpriteVisualElement class?

I have star.fxg file and i want create SpriteVisualElement class from String "star". I'm trying like this:

var classRef:Class = getDefinitionByName("star") as Class;
myStar = new ClassFactory(classRef).newInstance() as SpriteVisualElement;

but Flex say that Variable star is not defined .

But if i try:

myStar = new star() as SpriteVisualElement;

all working fine.

How to get instance of SpriteVisualElement from String name of fxg?

The answer is to use the fully qualified class name. Instead of star use com.myPackage.mySubPackage.star

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM