How to import FXG to a Shape?

流过昼夜 提交于 2019-12-08 11:53:51

问题


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 Shapes?


回答1:


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




回答2:


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!



来源:https://stackoverflow.com/questions/6928755/how-to-import-fxg-to-a-shape

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!