Dynamic Flash

Confessions of a serial code abuser
  • rss
  • Home
  • MTASC
  • Archives
  • About me
  • Goodies
    • Base64 encoder/decoder class
  • My Bookshelf
  • My Talks

Library.py 0.1: XML generation script for swfmill

Saturday, 23 April 2005

I’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.

Download library.py 0.1

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 ENC as the encoding XML declaration attribute value. Defaults to iso-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.

Categories
Flash
Comments rss
Comments rss
Trackback
Trackback

« MTASC 1.04 Linux MTASC 1.05 OS X »

5 responses

works great here, thanks! just for completeness, swfmill can be found

daniel | Sunday, 24 April 2005 | 5:39 am

works 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 pm

Type your commes a quick example of a python script being used to create nt here.

Leave a comment

You can use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="">

About Dynamic Flash

Steve Webster is a Senior Web Developer for Yahoo! in London, UK.

He is more than a little concerned that he defines himself in terms of his career, and that he talks about himself in the third person.

Find out more

Sponsored Links

del.icio.us-ed

  • msInterpolationMode Property
  • Box2DJS - Physics Engine for JavaScript
  • FireUnit: Firebug Unit Testing for Firefox
  • Best practices: 6 AIR features that may annoy your users | Serge Jespers
  • pulpTunes — Webserver for iTunes
  • To WebKit or not to WebKit within your iPhone app?
  • Accessible Forms using WCAG 2.0
  • CSS Transitions
  • typeface.js -- Rendering text with Javascript, <canvas>, and VML
  • Silverlight 2: Things ActionScript developers need to know.

Recent Posts

  • Upgrading your app to AIR 1.5
  • Motivate yourself by doing it in public
  • The trouble with Flash and REST
  • And we’re back
  • Slides and example code from <head> ‘08

Tags

Accessibility ActionScript actionscript3 actionscript 3.0 air apple astro book calendar conference designer filereference file upload Flash flex fotb08 framework getters head head08 head2008 headconference html5 http ical internet internet explorer JavaScript jobs junior microsoft opportunities representational state transfer rest ria schedule silverlight singularity08 skin tutorial urlrequest web developer web development Web Standards Yahoo!

Stuff

Singularity?
Flex.org - The Directory for Flex
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox