开发者

How to import FXG to a Shape?

开发者 https://www.devze.com 2023-03-24 18:51 出处:网络
I can import FXG files as Sprites as follows: import graphics.mypic; // graphics/mypic.fxg var mysprite:Sprite = new mypic();

I can import FXG files as Sprites as follows:

import graphics.mypic; // graphics/mypic.fxg
var mysprite:Sprite = new mypic();

I don't always need the fancy things that come with Sprites. How can I import them to Sha开发者_高级运维pes?


No, you can't cast them as Shape(s) - the internal compile-time FGX is built on top of Sprite. You can find that out by running

var tig:* = new tiger();
if (tig instanceof Sprite)
...

What George Profenza is referring to is runtime loading of FXG's


I don't know if there's a better way to do this know, but last year I've played with a nice FXGParser library that simplified things a lot.

  1. Get the library:

    svn export http://www.libspark.org/svn/as3/FxgParser/

  2. Use it:

    import fxgparser.FxgDisplay; import graphics.mypic;

    var fxg:XML = new XML(mypic);//this bit depends on how you load/embed the fxg xml var mysprite: FxgDisplay= new FxgDisplay( fxg ); addChild( mysprite );

Goodluck!

0

精彩评论

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