FlashCommand is a windows only program to call Flash MX 2004 Pro to publish or export a movie from the command line. This was developed by Mike Chambers. Mike developed this in his own time and has included the source.
Note: this is Windows only and requires the .NET framework.
You can find a version for Mac OS X (written in Python) here.