gskinner.com: gBlog: FlashMX 2004 source code, news, reviews and opinions
Back to gBlog Main gskinner.com website: source code, portfolio, etc. contact Grant Skinner

Syndication
RSS 1.0
RSS 2.0


Subscribe
Enter your email address to be notified when posts are added.

Search

Resources
Conference Session Notes

Flash Blogs
Waxpraxis
Philterblog
W3Blog
Jonas Galvez
Josh Dura
Quasimondo
Flashguru
Sean Voisen
Colin Moock
Flazoom
Greg Burch
Pope De Flash
Peter Hall
Glyn Thomas
actionscript.com
Princess Pegg


Aggregators
Flog
FullAsAGoog
MXNA
Hall of Justhese


« Internal Preloading in Flash MX 2004 | Back to Main | JSFL FLA Batch Compiler: Updated »

August 19, 2004


IMPORTANT NOTE: This is an old archive. It is only here to support outdated external links. To view the updated version of this archive, please go to the blog index, and search for the title of this document using the search form.

JSFL FLA Batch Compiler
Posted by Grant

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.

Usage:
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
assets/asset1.fla     swfs/assets/one.swf
assets/asset2.fla     swfs/assets/two.swf

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.

Limitations:
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.

Download
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.

Posted @ 10:44 AM by Grant | TrackBack


Comments

As for limitation #1, you can use fl.outputPanel.save();

As for #2, you can say:
fl.openDocument(fileURI);
fl.getDocumentDOM().testMovie(); // or publish()

Posted by: Keith Peters at August 19, 2004 10:51 AM

Thanks Keith,

#1 sounds like it will work... #2 won't work how I want it, because I'd like to be able to move the swf before I open it (had already considered using testMovie instead of publish).

Posted by: Grant Skinner at August 19, 2004 11:02 AM

#2: you can open swf-files by using fl.openScript().
there is no hint in the jsfl-docs about that but it works.

example:
fl.openScript("file:///c|/test.swf")

Martin

Posted by: Martin Eder at August 20, 2004 11:16 AM

Nice. Added this in and uploaded a new version - thanks Martin.

Posted by: Grant Skinner at August 20, 2004 03:03 PM

nice work ! thanx !

Posted by: Francis Bourre at August 22, 2004 02:36 PM

thanks a lot,
share your work is cool !

Posted by: Clément Hussenot at August 25, 2004 03:16 PM

Grant,
thanks for this, I'll post about this on my site.

Posted by: eyezberg at August 29, 2004 02:41 AM

To help generate the text file for batch compiling you can make a "filelist.bat" file comprised of the following command.

dir /a /b /-p /o:gen >filelisting.txt

Run this, then you can either add the individual profiles/paths where needed, or you can bring this list into MS Excel and using a copy/paste
macro generate your paths/profiles and export out the spreadsheet as a space delimited text file.

To be able to add this command to Windows Explorer
so you can generate file lists within any directory you're in, go to the following link to see how to add this as a custom file command within explorer.

http://www.theeldergeek.com/file_list_generator.htm

When you have to process literally hundreds of SWFs for flash courseware for example, this JSFL/Batch command combo is a MAJOR time saver. Thanks

Posted by: Kurt Melander at September 28, 2004 06:26 PM


Hosting by NetKeepers.ca | Powered by Movable Type 2.661
The text content of this blog is licensed under a Creative Commons License. Graphics are ©2003 Grant Skinner.