JSFL helpfulness

December 11th, 2004

Most of the projects I work on include many separate swf files that are loaded in at run time. This can be a pain because you have to publish multiple fla’s each time you want to test the project. BIT-101 had a helpful answer to this using JSFL. BIT-101′s solution works great if your only working on two files but I wanted something that would work on multiple files so I came up with this:

1
2
3
4
5
6
7
8
9
10
11
fl.outputPanel.clear();
fl.saveAll();
var currentWindow = fl.getDocumentDOM();
for(var a = 0; a < fl.documents.length; ++a){
    if(currentWindow != fl.documents[a]){
        fl.setActiveWindow(fl.documents[a]);
        fl.documents[a].publish();
    }
}
fl.setActiveWindow(currentWindow);
currentWindow.testMovie();

I ran into a problem where all the movies published were also tested all at once inside the same window. Im not sure what was going on there but making each document active before publishing it seemed to fix it.

BIT-101 bound the script to the F7 key. I added it to the JSFL script executed by hitting command-enter in Xcode as shown in the oh so helpful Xcode for flash tutorial.

Next up is to write an Xcode script that saves all unsaved actionscript files before telling flash to publish everything. But that will be for tomorrow… err… make that later today.

Leave a Reply