0

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?

Andy
  • 95
  • 1
  • 7

2 Answers2

3

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

Stepan
  • 31
  • 2
0

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!

Community
  • 1
  • 1
George Profenza
  • 50,687
  • 19
  • 144
  • 218
  • Is this really necessary? For importing it as a Sprite, the two lines in my question are enough. – Andy Aug 03 '11 at 18:11