Library.py 0.1: XML generation script for swfmill
Saturday, 23 April 2005I’ve created a Python script that will output ’simple’ swfmill XML, allowing you to pack whole directories of GIF, JPEG, PNG and SWF assets into a shared library swf with the minimum of fuss.
Usage
library.py [options] [paths]
Options
-r, --recursive- Include subdirectories of
[paths]in the search for assets. -c ID, --clip=ID- Create an empty clip with an id of
ID. You can have as many of these arguments as you need. -e ENC, --encoding=ENC- Use
ENCas theencodingXML declaration attribute value. Defaults toiso-8859-1.
Assets are exported with an id of the base part of the filename, so a file called DynamicFlash.png will have an id of DynamicFlash.
Examples
To generate ’smple’ XML for all the assets in a folder called ‘assets’, including subfolders:
> library.py -r assets
<?xml version=”1.0″ encoding=”iso-8859-1″?>
<movie width=”1″ height=”1″ framerate=”12″>
<frame>
<library>
<clip id=”at” import=”assets/at.png”/>
<!–– more ––>
</library>
</frame>
</movie>
This will output the XML to the command line, which isn’t exactly useful except to make sure that the script is behaving as it should. If you get an error message instead of XML you may need to invoke Python manually:
> python library.py -r assets
<?xml version=”1.0″ encoding=”iso-8859-1″?>
<movie width=”1″ height=”1″ framerate=”12″>
<!–– etc. ––>
</movie>
Once you manage to get some likely looking XML, run the command again, this time redirecting the output to a file called library.xml:
> library.py -r assets > library.xml
…and then using this file to feed swfmill:
> swfmill simple library.xml library.swf
swfmill 0.2.2
Reading from library.xml
Writing SWF to library.swf
SWF saved to library.swf (457775 bytes).
Congratulations. If your output from swfmill looks like the above, you’ve just created a shared library swf file packed with all your assets.
You can avoid having to create an intermediary XML file by piping the output directly into swfmill:
> library.py -r assets | swfmill simple stdin library.swf
swfmill 0.2.2
Reading from stdin
Writing SWF to library.swf
SWF saved to library.swf (457775 bytes).
The key here is the second argument to the swfmill command. Usually swfmill required you to specify the name of an xml file to parse here, but stdin tells swfmill to parse the standard input stream instead. Using a pipe (denoted by the | symbol) we direct the output of library.py to the input stream of swfmill, cutting out the need for an intermediary file.
END
That’s all the documentation I’ve got time for. Have a play around, and if you’ve got any suggestions or feedback them please let me know via the comments here.








works great here, thanks! just for completeness, swfmill can be found
daniel | Sunday, 24 April 2005 | 5:39 amworks great here, thanks!
just for completeness, swfmill can be found here.
[...] s a quick example of a python script being
COLLCOLL » Blog Archive » Open Source Nerding | Saturday, 11 June 2005 | 7:04 am[...] s a quick example of a python script being used to create a shared library file of images: http://dynamicflash.com/2005/04/library-dot-py-01/ This entry was po [...]
[...] Library.py 0.1: XML generation script for swfmill at Dynamic
Library.py 0.1: XML generation script for swfmill at Dynamic Flash « Ramblings | Tuesday, 28 November 2006 | 2:31 pm[...] Library.py 0.1: XML generation script for swfmill at Dynamic Flash: [...]
[...] Library.py 0.1: XML generation script for swfmill…Python script that
Bookmarks for April 15th at Necessary Madness | Monday, 16 April 2007 | 1:08 am[...] Library.py 0.1: XML generation script for swfmill…Python script that will output ?simple? swfmill XML, allowing you to pack whole directories of GIF, JPEG, PNG and SWF assets into a shared library swf with the minimum of fuss…python flash tool development [...]
Type your commes a quick example of a python script
murtazaaa | Sunday, 23 September 2007 | 10:02 pmType your commes a quick example of a python script being used to create nt here.