开发者

Odd getDefinitionByName behaviour - not import related

开发者 https://www.devze.com 2022-12-18 23:02 出处:网络
Searching the web there are hundreds of answers to why getDefinitionByName doesn\'t work - because the class definition that you are trying to get is not included in the swf.

Searching the web there are hundreds of answers to why getDefinitionByName doesn't work - because the class definition that you are trying to get is not included in the swf.

This is not that problem.

My app is loading a swc at run time, unzipping it, reading the xml and displaying a list of classes that were in that swc. You can then select a class and it will be added to the stage.

When I load the swc and try to use getDefinitionByName I get the following trace:

getting class: com.company.assets:AppFooterShadow

error: Error #1065: Variable assets:AppFooterShadow is not defined.

The com.company is stripped off the beginning!

From code similar to this:

try
{
    trace( "getting class: " + definition );
    var 开发者_C百科currentClass : Class = getDefinitionByName( definition ) as Class;
}
catch( e : Error )
{
    trace( "error: " + e.message );
}

If I type a class name in a text input box and try to load that it works fine - with exactly the same string being passed to the function.

Anyone got any idea what is going on here? Seems very odd to me.


I can't believe how long I've been staring at this and not seeing what the problem was!

I had typed in this:

com.company.assets.AppFooterShadow

and this was in the list:

com.company.assets:AppFooterShadow

a colon instead of a full stop!

Ok I'll stop talking to myself - please ignore this!

0

精彩评论

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

关注公众号