1

I have a series of large fla files that were being published into swc's and then used directly in an flash project. Probably a total of 1000+ objects. As the number grows the final compiled swf is getting quite large so I want to download individual swf's of each object only as needed. I then need to be able to access and clone the object via classname from the final AS project.

The issue is the only way I have found to export each one is to 1) copy and paste it into a new fla file 2) double click to 'edit' it to force it included, 3) reset the linkage (class) name since it was wiped, 4) publish (i.e. file->publish) and name this swf.
This will take quite a while for 1000+ of these.

While you can right-click on each item in the library to save it as a swf, it appears NOT to include the classname etc, just the item. Once I download this, I cannot clone to use it more then once without downloading it again which is unacceptable.

Is there a faster/better way to generate these swf's?

(I did look into xfl briefly but it looks like writing a script to do this given some of the unknowns there will take longer then just doing it by hand.)

Preston
  • 68
  • 5

1 Answers1

1

You should have a look at JSFL which allows you to extend Flash/write a script that will automate this task for you.

You could for example write a script that loops through elements in the library and exports swf only for movieclips that are exported for actionscript, and generates a bit of LoaderMax code which is placed in the clipboard when the export is complete:

var doc   = fl.getDocumentDOM();
var dir   = 'file:///' + doc.path.substr(0,(doc.path.lastIndexOf('/')+1));
var lib   = doc.library;
var code  = 'var queue:LoaderMax = new LoaderMax({name:"queue"});\n';
var items = lib.items;
var iNum  = items.length;
var path;
var name;

fl.outputPanel.clear();

for(var i = 0 ; i < iNum ; i++){
    if(items[i].linkageExportForAS){
        name = items[i].linkageClassName;
        path = dir+name+'.swf';
        items[i].exportSWF(path);
        code += 'queue.append( new SWFLoader("'+name+'.swf", {name:"'+name+'"));\n';
    }
}

fl.clipCopyString(code);
fl.outputPanel.trace('symbols exported as swfs, code is in your clipboard');

Save this as a .jsfl file to run it, place it in Flash(IDE)'s Commands folder and it will pop in Commands menu in the interface.

This not perfect, but it gives an idea of what can be done.The first thing is to establish a workflow I imagine, then to write the scripts for it.

There a few things I didn't understand though, I'm trying to break it down:

I have a series of large fla files that were being published into swc's and then used directly in an flash project. Probably a total of 1000+ objects. As the number grows the final compiled swf is getting quite large so I want to download individual swf's of each object only as needed.

So there are some fla with assets that need to be coded later on. I imagine a swc will contain multiple MovieClips exported for actionscript and there are probably more fla files with different types of assets.

I then need to be able to access and clone the object via classname from the final AS project.

Do you mean instantiate classes from swf files, using getDefinition ?

The issue is the only way I have found to export each one is to 1) copy and paste it into a new fla file 2) double click to 'edit' it to force it included, 3) reset the linkage (class) name since it was wiped, 4) publish (i.e. file->publish) and name this swf.

For step 1, can you not right click the MovieClip and choose ExportSWF/ExportSWC(depending on what you need) ? I don't understand what you mean by 'force it included'. Do you mean tick Export for Actionscript ? Who/What wipes the linkage ?

George Profenza
  • 50,687
  • 19
  • 144
  • 218
  • Thanks for the scripting idea, I will take a look. In response to your questions. 1) Either via getDefinition or just by getting the contructos (e.g. Object(mc).contructor) as an example. 2) For what ever reason, when you right click, even on an asset with export for actionscript checked and a class name set, it does not include the class information. Only if you use the file->publish does it get included. no idea why. – Preston Jan 11 '11 at 01:01
  • @Preston Could it be an issue similar to this one( http://stackoverflow.com/questions/1004867/compile-a-swc-in-flash-for-use-in-flex-with-a-class-written-in-flex ) ? – George Profenza Jan 11 '11 at 01:11
  • I think that one is kind of the opposite problem. I am currently embedding everything and need to move away from that – Preston Jan 11 '11 at 02:00
  • @Preston Then I imagine you would organize your assets based on 'sections' and use LoaderMax to load the main assets that you need to run the application first, and then rest as user navigate through it. You will probably end up with a few swf files that will contain loads of MovieClip symbols, grouped by how they're needed in the app, and will need to refactor some bits where you initialize everything at once...this is just a wild guess. – George Profenza Jan 11 '11 at 02:14
  • @Preston I would say work out what bits go where on paper first, do a simple test for loading/accessing classes to make sure the setup is correct, then write/modify the jsfl script that will loop through the new clean flas and export what's needed in the right place/format and possibly even generate some code(as3/xml/whatever you fancy for keeping track of the assets). – George Profenza Jan 11 '11 at 02:15
  • Well having played with your script above I think I am most of the way there. For some reason, it exports ALL the library elements into each swf it produces but given the robustness of JSFL I am sure I can get it to work in due course. Thanks. – Preston Jan 12 '11 at 18:46