RegExr v2: Build, Test, & Lear…
A Meandering Path to an Evolvi…Quick as a FlashThings Every ActionScript Deve…Making Money with Adobe AIRUsing Flash for 3D Game MMO UIUtilizing Flash for Game UI De…Why I (Still) Love FlashMy Favourite Things
Posted on August 19, 2004 by Grant Skinner
One of our current projects has over 50 FLAs, all of which need to be compiled, and organized into the proper directories on a regular basis. I got bored of trying to remember what had to be compiled, and doing it all manually, so I wrote a simple JSFL script that compiles and moves them all for me (it also does other interesting stuff, like update import linkage URLs depending on whether I’m doing a production or dev build, but more on that later). It also generates a handy-dandy log of the process.
I thought this might be useful for other people, so I spent a bit of time making it more generic and easy to use. Here are some instructions on how to use it – you can download the script and a simple usage demo at the end of this post.
To use this script, you must set up a compile schema file for your project. This is just a simple text file in the format:
FLAPath SWFPath PublishProfileName
FLAPath SWFPath PublishProfileName
Each line represents a single compile action, and is comprised of the path to the FLA (in URI format, relative to the location of the compile schema file) followed by a single tab, then the path that you want the SWF moved to (again, URI relative to compile schema), and finally another tab character followed by the name of the publishing profile you wish to use. Both the SWF path and publish profile are optional – if the SWF path is omitted, it will simply compile the FLA and leave the SWF in its default location, if the publish profile is omitted it will just use the default profile. A finished schema might look like:
core.fla swfs/myCore.swf testProfile
The first line would tell the compile script to compile core.fla in the same directory as the compile schema using the testProfile publishing profile, then move the swf into the swfs directory and rename it myCore.swf.
Once the schema is set up, you simply run the command (Command menu: Run command… or by adding it to your commands list), select your schema in the file dialog that opens and grab a coffee. The command will compile your files according to your schema and generate a lovely verbose log file called “compile_log.txt” in the same directory as your schema.
There are, unfortunately, a couple of limitations – perhaps some JSFL gurus have some work-arounds to these (if so, please post in the comments):
1) Doesn’t log publish errors – there doesn’t seem to be any way in JSFL to access the contents of the output panel or any errors output by a publish call. UPDATE: Fixed – will now log publish errors. Thanks to Keith Peters for the heads up on fl.outputPanel.save().
2) Doesn’t launch your main swf – I wanted to make it automatically launch the first swf generated when it finished compiling, but I can’t see a way of making Flash do this in JSFL.
3) As with any JSFL that uses the FileAPI, I would recommend caution in using this script – I took a lot of care in making this safe to use (and have been using it on my system), but there are no guarantees that it won’t thrash something.
You can download the JSFL file, and a simple demo of it in use by clicking here. Be sure to read the disclaimer in the JSFL source before using. Hope this helps someone.
Follow @gskinner on Twitter for more news and views on interactive media.