Flash 8

Hey Folks,

Anyone know if we can script Flash 8 using Applescript? I have to export Quicktime Video and/or PNG Sequences from literally hundreds of files each week, and was hoping to automate it, since they all have the same settings. We’ve currently done this by scripting it using keystrokes (tell the app to open the right menu item, then use tabs and keystrokes, etc., to actually export the files) but with this method we can’t set the timeout so that the files finish exporting before starting the next file in the list.

Anyone know if we can access methods from Flash and have the Apple event sent back to the script to let it know that it can continue? Or should we just create some sort of timer to check the status of the file(s) being created, and if there is no change in filesize on the current file(s) being exported, then move on to the next item?

Sorry if this sounds confusing - I’m running around like a chicken with my head cut off today and haven’t been able to really compose myself well enough to think about how to describe the problem. :confused:

Hopefully someone’s found a way to script Flash! :slight_smile:

Deep (just a guy)

Model: PowerMac G5/2GB RAM/1TB S-ATA RAID
AppleScript: 3
Browser: Safari
Operating System: Mac OS X (10.4)

The way to go with Flash automation is JSFL. It will allow near to anything you can do with the UI (including batch export actions). If you are an experienced actionscripter, just make a new “Flash JavaScript File” and explore the methods and objects. You have Macromedia Exchange (with a section specific to JSFL) and tons of help in various online sources. I use this mailing list: http://lists.flashguru.co.uk/mailman/listinfo/extendflash

Anyway, I still use AppleScript UI scripting to save Flash 7 files to 6 (this feature is not implemented in JSFL), so perhaps you can find some tricks here: http://homepage.mac.com/julifos/soft/beta/flash7_to_flash6.zip

The trick is checking for UI elements. For example (this is a quick thought), if you are exporting a .fla, you can check for the existence of a window called “Exporting blah”. If it does, wait. If it doesn’t, it finished exporting and you can continue.

  • NOTE: this Flash 7 to 6 script should be edited to make it work properly, as it is fully adapted to my machine and settings.

Sorry for the late response! Been crazy around here. :frowning:

Thanks for the tips! I’d actually looked at JSFL (hand-coded - totally didn’t even realize that there was an interface to code it within Flash! Nice!) Unfortunately, there are exportPublishProfile, exportPNG and exportSWF methods, but nothing for exportMOV (most likely cuz only Macs really handle real Quicktime Video - PCs have AVIs instead) and nothing for exportWAV or exportAIFF (again, platform-specific issues are why I’m guessing these were never built). exportPublishProfile doesn’t work for me, as I need to export PNG or BMP sequences, as well as Quicktime Video or WAV files. Poopy.

The script you sent over is cool and I’ll have to dig further when I get a chance (I’m stuck on Linux/Win at my desk and am trying to create these scripts for our offline editors who work in Final Cut Studio) - we’d already implemented a quick script to use the menus to get to the export movie dialog (as opposed to just using keystrokes), and used Applescript to edit the .plist files to make sure out export paths were correct, but we haven’t been able to edit the settings other than in the most clunky way possible (using ‘tab’ keystrokes to get to the desired spot in the export window, and then typing in whatever is needed to switch the settings). Needless to say, this solution is ugly. More control of the export functions would be awesome. Also, another problem is that our script times out whenever the exports are happening, unless we set a large delay (some of our files have some very complex artwork, so exporting the scenes takes forever) and we don’t have any way to really check to see if Flash is still busy before getting the rest of the Applescript stuff to continue.

Here’s a general outline of what our script is doing:

start {
read a directory full of FLAs
for each file in the directory {
edit the plist to set the PNG export location
open Flash and export the file as a PNG sequence
delay 220 (sometimes it can take almost 4 minutes to export a sequence)
quit Flash
edit the plist to set the MOV export location
open Flash and export the file as a Quicktime Video
delay 220 (same reason for the delay)
quit flash
double-up the frames in the PNG sequence
open the MOV with QT Pro and export to a WAV using a pre-formed .qtes with timeout of 180
open the PNG sequence with QT Pro and export to a MOV using a pre-formed .qtes with timeout of 180
open Cinema Tools and run a Batch Conform the newly-created MOVs to 23.98fps
use a preset setting in Compressor to batch convert the files to non-square pixels

not sure if this helps or not? Currently this works, but the delays of 220 each time we export from Flash are just too long, especially since it’s only about 5-6 files out of every 300 that needs a delay of that length. Some possible solutions I’ve thought of are:

  1. Poll the PNG directory to see if there is a change in the number of files since the last check; if yes, export is still running so delay 2 seconds and repeat the poll; else continue with the next step
  2. Check the MOV being exported by Flash, and if it’s still being written, then delay 2 and repeat the check; else continue with the next step

But I’m not sure if this might get caught as an infinite loop if it runs too many times while waiting for Flash to finish…thoughts?


Deep (just a guy)

There are lots of ways to do it… For instance, this works fine here (JSFL):

You must only place your publish profile called “Cool One” within the Publish Profiles dir (eg, using QT in your settings), and let Flash do the job: open the first one of a serie of .fla files, and it will export using the publish profile, plus the .png sequence in a programatically created “PNGs” dir (obviously, you can adaptate this script).

If you want drive it using AppleScript (in order to drive later Cinema Tools, etc.), you could simply tell app Finder to open file “path:to:script.jsfl” using Flash 8, then add some lines in the JSFL script to create a dir called “DONE” somewhere when it ends, then make the AppleScript check periodically for the existence of such dir, and continue later with the rest of your task…

Interesting! Thanks so much for this. I was, for some reason, under the impression that exportPNG only handled single-frame PNGs. This is awesome! As for polling for a directory, that would be easy to do - we could actually just use the JSFL File API to write to a file which the script polls, which could double as a log (which would be nice for reports in case of any hiccups in the process, too!)

Now to make sure that we have a way to export the MOVs as well. But heck, this has totally derailed from an AppleScript discussion now - I’ll move my sorry behind on down to a JSFL forum and leave this for what it should be all about. Thanks so much for all the help!!!

Deep (just a guy)