fla2swf - command line utility for publishing .fla files to .swf

Continuing my flash automation saga this time I’m going to blog about a fla2swf utility, as I promised in the previous post about fcshd. You can grab it in the downloads section of the flash-automation project.

fla2swf is a command line utility written in PHP which can be used in a batch mode for publishing .fla files to .swf. It consists of the client and server parts. The cool thing behind this utility is the fact the client can be run on the box without Flash IDE installed(even on the *nix box). Of course, you will need the server to be run on the workstation with the Flash authoring environment installed.

This is what fla2swf is doing behind the scenes:

  • fla2swf client passes all publishing requests to fla2swfd server and writes back the results. The client accepts paths to .fla files and corresponding paths to resulting .swf files. Internally fla2swf sends .fla files to the server as binary blobs, it accepts the binary blobs of the resulting .swf files and writes them onto the disk. fla2swf is a cross-platform client which was tested both on *nix and Windows.
  • fla2swfd server accepts series of .fla files as binary blobs. It creates an appropriate jsfl script for publishing .fla files into .swf, executes it and returns back binary blobs of the published .swf files. Due to tight integration with the Flash IDE fla2swfd can be run on Windows only(though it should work on Mac as well with minor changes)

After unzipping the archive, enter the fla2swf directory and invoke the usage help by simply running the script:

$ php fla2swf.php
No fla/swf files specified
  fla2swf.php [OPTIONS] <fla_file> <swf_file> [<fla2_file> <swf2_file>, ...]
  --host       - fla2swfd host(by default tries the first ip returned from ipconfig)
  --port        - fla2swfd port(8976 by default)
  --force=1   - force the publish process(i.e don't stop the publishing if the last
                    modification time of the resulting .swf file is newer than of the
                    source .fla file)
  --noauto=1  - don't try to spawn the fla2swfd daemon automatically
  <fla_file> <swf_file> - pairs of .fla => .swf files. Amount of such pairs is unlimited

The typical usage of of the fla2swf can be as follows:

$ php fla2swf.php hud.fla hud.swf menu.fla menu.swf avatar.fla avatar.swf
start  "fcshd"  /MIN php fla2swfd.php --host= --port=8976
Connecting to '' at port '8976'...
Sending request...
Waiting for reply...
hud.fla(53601 bytes) -> hud.swf(69568 bytes)
menu.fla(54302 bytes) -> menu.swf(73566 bytes)
avatar.fla(67642 bytes) -> avatar.swf(89562 bytes)

fla2swfd.JPGBy default if fla2swf is run on the Windows host and if the server host is not specified or matches the client host, fla2swf spawns the server automatically. Once the server is running you should see the fla2swfd window running minimized.

I’m using this utility in the project build pipeline and pretty much satisfied with it. It helps avoid storing the final .swf files in the repository. In my practice, storing exported files in the repo can be a constant source of conflicts and leads to a bloated repository size(this is especially true for distributed source control systems where you can not easily truncate the commit history). It probably has some bugs but I have not faced any so far. Enjoy :)

One Response to “fla2swf - command line utility for publishing .fla files to .swf”

  1. My desperate life quest for efficiency » Blog Archive » Cross-platform convenience wrapper around fcsh (for fast incremental Flex builds) Says:

    […] Making FuzzyFinder vim plugin really convenient (a-la TextMate “Go to file”) fla2swf - command line .fla to .swf publishing utility […]

Leave a Reply