开发者

getDefinitionByName in Flash Builder acting racist to new classes after switching to FB 4.5.1

Does anyone know why the getDefinitionByName function works with "com.foo.Bar" and gives error with "com.foo.Rab"?开发者_如何学C

My only clue is that the class com.foo.Bar was created before importing the project to Flash Builder 4.5 for PHP (4.5.1 namely).


My question is very specific, in fact you could try for yourself if you had FB4.5.1, a prior version of the same program, and a lot of time. Obviously I’m hoping to find someone who have experienced this particular issue or any related issue with similar functions.


I'm porting a card game from pure Flash/AS3 to Flex 4.5 and in the original app I was using getDefinitionByName to load card MovieClips from the library dynamically:

var sprite:Sprite = new (getDefinitionByName(spriteName) as Class);

But in my Flex app I don't use it anymore. Instead I have this class - Assets.as:

package {
    public class Assets {
        [Embed('assets/Pref.swf', symbol='spades_Q')]
        public static const SPADES_Q:Class;

        [Embed('assets/Pref.swf', symbol='clubs_Q')]
        public static const CLUBS_Q:Class;

        [Embed('assets/Pref.swf', symbol='diamonds_Q')]
        public static const DIAMONDS_Q:Class;

        [Embed('assets/Pref.swf', symbol='hearts_Q')]
        public static const HEARTS_Q:Class;

        ....

and then in my main class I use:

var sprite:Sprite = new Assets[spriteName];

for example:

var sprite:Sprite = new Assets['HEARTS_Q'];

Maybe this helps you?


getDefinitionByName can only import classes that are already present in the current ApplicationDomain. Your app must import com.foo.Rab in the normal fashion earlier in the execution or it will not work.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜