Export .swf clips to a json/png format from the command line

@Mark Bavis Mark Bavis authored on 25 Sep 2019
flash Pass in base_dir and out_dir on a per-command basis for stdin processing 5 years ago
.gitignore Work on splitting up the driver into multiple files (we can ignore the .pyc files this produces) 6 years ago
args.py Wasn't processing the out_dir argument properly or passing any base arguments to Job 6 years ago
driver.py Removed all old .as files from the original GraphicExport project, and move everything into a flash/ folder, and then into proper folders inside of that. Also fixed the ./exporter.py script to find the Exporter.exe no matter which folder it's run from, and make sure we include the resource names in both .graphic and .asset styles (and if there's only 1 resource file for an asset, don't append _0000 digits) 5 years ago
exporter.py Pass in base_dir and out_dir on a per-command basis for stdin processing 5 years ago
files.txt Sending messages properly back and forth using the new driver architecture, and a proper message queue+program completion 6 years ago
job.py Clean up the data in the 2 types of exports 5 years ago
readme.md Added readme.md 5 years ago
validate.py Actually writing out graphic data now (if it's a single graphic, just write the .graphic file with the data inline, otherwise write .graphic for each graphic and .asset for the total data) 6 years ago
readme.md

SWF Exporter

Given source files explaining how to export .swfs, export them.

usage: ./exporter.py [--out dir] [--base dir] source1 source2 source3 ...

Or, if you're not using git bash or some shell that supports shebangs: python exporter.py source1 source2 source3 ...

Source files are JSON files explaining how to export swf(s). They look like:

{
  "graphics":[
    {"swf":"path/to/file.swf"
     [,"scale":1]            // scale exported images, default = 1
     [,"type":1]            // 1 (default) for spritesheet export
                            // 2 for skeletal export
     [,"name":"ExportName"]                      // defaults to swf file name
     [,"class_name":"ClassNameOfClipInSwf"]}  // defaults to swf file name
  ],
  ...
}

The graphics array specifies the swfs to export. If only one swf is specified, that swf will be exported with all its graphics in a .graphic file given by the name parameter. If multiple swfs are given, the graphics required for all of them will be exported to a single .asset pack file given by the name of the source file, and individual .graphic files will be created for each graphic under their name, with a single reference pointing to the pack file.

Example source files:

  1. {"graphics":[{"swf":"Player.swf"}]} produces:
    • Player.graphic, containing all the images/sprite info for Player.swf
  2. {"graphics":[{"swf":"Player.swf"},{"swf":"Fighter.swf","name":"Enemy"}]} (given as Characters.src) produces:
    • Characters.asset, a pack file containing all the graphics from Player.swf and Fighter.swf
    • Player.graphic, a JSON file with a single property pointing to the entry Player in Characters.asset
    • Enemy.graphic, a JSON file with a single property pointing to the entry Enemy in Characters.asset

In the 2nd case, you can either load Characters.asset directly, and parse all of the entries in it; or, if you use dynamic loading by requesting a graphic name, requesting the graphic Player should cause Player.graphic to be loaded, and the redirection in that should cause Charaters.asset to be loaded, which should load both Player and Enemy into your game.

Folders

Graphics are given a path when exported, relative to the base option, or, if that option is not given, the current directory. Output files are put in a path relative to the out option if given, or the current directory if omitted.

For instance, exporting Player.src by running ./exporter.py --base ./graphics --out ./build/assets ./graphics/players.Player.src will generate the file ./build/assets/players/Player.graphic

Automation

Running ./exporter.py [--out dir] [--base dir] - causes the script to read from stdin; every line will be parsed as an option set [--out dir] [--base dir] source_file. Useful for automation, for example:

find ./graphics -type f -name '*.src' | ./exporter.py -