Generating individual SWF's with classes from a fla with a large library

蓝咒 提交于 2019-12-24 16:11:15

问题


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.)


回答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 ?



来源:https://stackoverflow.com/questions/4652883/generating-individual-swfs-with-classes-from-a-fla-with-a-large-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!