Don't think so, you might need to load the whole swf before using getDefinition().
A workaround I can think of is splitting the swf into many different ones.
Either naming the swf's by the class they contain, or storing some swf filename/contained classes pairs in a text file/xml and using that to load resources by name.
Have a look at BulkLoader, it could save you some time.
If you're using the Flash IDE, I wrote a simple jsfl script that should make things
less tedious:
var doc = fl.getDocumentDOM();
var dir = 'file:///' + doc.path.substr(0,(doc.path.lastIndexOf('/')+1));
var lib = doc.library;
var code = 'var loader : BulkLoader = new BulkLoader("assets");\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 += 'loader.add("'+(name+'.swf')+'", {id:"'+name+'"});\n';
}
}
fl.clipCopyString(code);
fl.outputPanel.trace('symbols exported as swfs, code is in your clipboard');
All it does is loops thought the library items, and for the symbols that are exported for actionscript, it exports a swf file(where the Class name is used as a filename), and generates a bulk-loader snippet.
Easiest way to get it into Flash is this:
- Create a new Flash JavaScript
File (File > New > Flash
JavaScript File)
- Paste the code
- Save the file as ASSymbolsToFiles or something. It the file should
default to the Commands folder,
which means you could use it through
the Commands menu. You can also
set a keyboard shortcut, if needed.
The generated code might not be perfect, but it gives you an idea, and it should be readable enough for easy tweaks.
HTH,
George