Wednesday, September 15, 2010

Swftools : An Introduction

What is it : A bundle of tools for finding information/manipulating swfs.
Where do I get it from : Here.

Examples : 
1. Merging two swfs : 
swfcombine.exe -a swf1.swf swf2.swf -o output.swf

2. Dumping information about a swf
swfdump.exe -a some.swf

3. Finding all the exported symbols from a swf : 
swfdump.exe -a some.swf | grep -i exports

Formatting source code for blogging

http://formatmysourcecode.blogspot.com/

JSFL script - iterates over many flas and create swfs for individual symbols


/*
   script tested with Flash CS5,
   should work with older versions.
 */

function universe() {
    var flaPath = "file:///../new_assets/";
    var outputDirPath = "file:///../../../code/trunk/client/game/city/resources/assets/";
    var flaFiles = FLfile.listFolder(flaPath + "*.fla", "files");
    var numFiles = flaFiles.length;
    for (var i = 0; i < numFiles; i++) {
        var flaFilePath = flaPath + flaFiles[i];
        fl.trace("reading "+flaFilePath);
        var doc = fl.openDocument(flaFilePath);
        var items = doc.library.items;
        var iLen = items.length;
        for (var j = 0; j < iLen; j++) {
            var item = items[j];
            if(item.linkageExportForAS) {
                var outputFilePath = outputDirPath+item.linkageClassName+".swf";
                if(fl.fileExists(outputFilePath)) {
                    fl.trace(outputFilePath + " already Exists, you sweet a*s");
                    //return;
                } else {
                    var tmpDoc = fl.createDocument();
                    tmpDoc.addItem({x:0,y:0},item);
                    tmpDoc.exportSWF(outputFilePath);
                    fl.closeDocument(tmpDoc);
                    //fl.trace("exported "+outputFilePath);
                }
            }
        }
        fl.closeDocument(doc);
    }
}
universe();

Blog Archive