Re: Haxe Digest, Vol 37, Issue 46

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Re: Haxe Digest, Vol 37, Issue 46


Hi Jon,

I have done a lot in this area so maybe I can help out. The latest
version of SWFMill does import inkscape svg graphics very well. So all
you need to do is use an swfmill template something like this with all
your clips inside.

<?xml version="1.0" encoding="iso-8859-1" ?>
<movie width="320" height="240" framerate="12" version="9">
  <background color="#ffffff"/>
      <clip id="MyGraphic" import="mygraphic.svg"/>

Then in haxe use the -swf-lib parameter to include the swfmill
generated swf and reference them inside haxe with code such as this
(taken from the haxe doc page).

class Test {
   static function main() {
         var s = flash.Lib.attach("MyGraphic");

You can read a little more about using library assets on the haxe doc
site here One final note regarding
layout would be to make sure your inkscape graphics are placed at the
top left of the document. That way when they are rendered into the
stage that will be their x/y point. I made the mistake of not doing
that thinking it would strip away the white space and was very
confused where this extra 200 pixels of padding was coming in.

Hope that helps, and if you're looking to load the swfmill files on
demand with the as3 loader I can help out there as well.

--Daniel Daley--

Thanks Daniel, that worked like a charm - I'd already sussed out most of the XML stuff (maybe I should have Googled a bit more first 8-)), the only change to the XML file was that I added a name attribute next to the id one with the same value - I'd read elsewhere that this was required to correctly setup references for bitmaps and I thought better safe than sorry.
Also on the haXe side - originally I tried creating an instance of a new class of type <name> (like in my bitmap example) extending a MovieClip, but I kept getting a blank screen, using the attach method worked first time, I might even try that with my bitmaps to try and clean up the code a little.
One last note (in case anyone references this later) my first test consisted of a circle and a couple of boxes, the boxes displayed fine but not the circle - it soon dawned on me that I needed to make sure that all the objects in the scene were converted to paths and then the display was perfect.  I didn't try setting gradients or anything, I suspect they may cause a few problems but nothing that can't be overcome!

haXe - an open source web programming language