When Getting Started doing Flash development it may be helpful to create assets.

The documentation for swfmill is somewhat difficult to track down, especially the simple function the following summary may be useful.

Make the Xml-file (asset_lib.swfml):

<?xml version="1.0" encoding="utf-8"?>
<movie width="60" height="20" framerate="20" frames="1" as3="1" version="9">
         <sound id="audio_01" import="sound/bgm.mp3"/>
         <clip id="clip_01" import="swfs/library.swf"/>
     <clip id="clip_02" import="image/background.png"/>
         <bitmap id="image_01" import="image/arrow.png"/>
         <font id="font_01" import="library/vera.ttf" glyphs="0123456789"/>

         <import file="library/library.swf" url="http://foo.com/library.swf"/>

Please, note following undocumented attributes:
- frames attribute should correspond total number of frames in the movie
- as3 attribute should be set to 1 if you want create AVM2 compatible movieclips

Run from command line

swfmill simple asset_lib.swfml  asset_lib.swf

In order to make use of the swf library thus produced an asset_class.hx needs to created from the asset_lib.swfml.
The asset_class.hx is then imported into those classes that make use of the library.

<?xml version="1.0"?>

<xsl:transform version="1.0"
<xsl:output indent="no" omit-xml-declaration="yes"
                method="text" encoding="UTF-8" />

<xsl:template match="/">
import flash.display.Bitmap;
    <xsl:for-each select="//bitmap">
class <xsl:value-of select="@id"/> extends Bitmap
     { public function new() { super(); } }
    <xsl:for-each select="//clip">
class <xsl:value-of select="@id"/> extends MovieClip
     { public function new() { super(); } }

    <xsl:for-each select="//sound">
class <xsl:value-of select="@id"/> extends MovieClip
     { public function new() { super(); } }

xsltproc  -o asset_classes.hx library.xslt  asset_lib.swfml 

And don't forget to mention asset_lib.swf when compiling with haxe:

-swf-lib asset_lib.swf

version #9243, modified 2010-09-15 12:36:22 by fidlej