In case you need too, this little Flash IDE script will let you publish every single Flash timeline layer as a separate SWF file. Just use unique and URL save layer names and you will get all your SWFs dynamically created as flaFilename + layerName + ".swf"
.
Just save this little code as a .jsfl file and open it with the Flash IDE:
function filterLayers( timeline, layerName ) { var layers = timeline.layers, layer, c, i; for ( i = layers.length - 1; 0 < i; i-- ) { layer = layers[ i ]; if ( layer && layer.layerType !== "folder" && layer.name !== layerName ) { timeline.deleteLayer( i ); } } } function publishNewFile( fileURL, layerName ) { var document = fl.openDocument( fileURL ); if ( document ) { var documentDOM = fl.getDocumentDOM(); if ( documentDOM ) { var timeline = documentDOM.getTimeline(); if ( timeline ) { filterLayers( timeline, layerName ); } } document.publish(); document.save(); document.close(); } } function layerToSWF( layerName, fileURL, fileName, parentDirURL ) { var newFileURL = parentDirURL + layerName + ".fla"; // create new file as copy var success = FLfile.copy( fileURL, newFileURL ); if ( success ) { // publish new file publishNewFile( newFileURL, layerName ); // remove new file (but leave SWF). FLfile.remove( newFileURL ); } else { alert( "Copy from\n" + fileURL +"\nto\n" + newFileURL + "\nfailed." ); } return success; } function timelineToSWFs( timeline, fileURL, fileName, parentDirURL ) { var layers = timeline.layers, layer, i = 0; c = layers.length; for ( i; i < c; i++ ) { layer = layers[ i ]; if ( layer && layer.layerType === "normal" && layer.name ) { if ( ! layerToSWF( layer.name, fileURL, fileName, parentDirURL ) ) { break; } } } } function layersToSWFs() { var fileURL = fl.browseForFileURL( "open" ); if ( fileURL ) { var document = fl.openDocument( fileURL ); if ( document ) { var documentDOM = fl.getDocumentDOM(); if ( documentDOM ) { var timeline = documentDOM.getTimeline(); if ( timeline ) { var parentDirURL = fileURL.split( "/" ); var fileName = parentDirURL.pop(); fileName = fileName.split( "." ); fileName.pop(); fileName = fileName.join( "." ); parentDirURL = parentDirURL.join( "/" ) + "/" + fileName; timelineToSWFs( timeline, fileURL, fileName, parentDirURL ); } } } } } // http://blog.derRaab.com - saves you some time - get yourself some fresh air! ;) layersToSWFs();
Have a nice day!
I was wondering is it possible to do this but output a image sequence instead of swfs?
Well, I think so, http://help.adobe.com/en_US/flash/cs/extend/WS5b3ccc516d4fbf351e63e3d118a9024f3f-7ffa.html might be a good starting point. 🙂
I know this is years old, but it is exactly what I want to do…
Tried it out (with CS6) and it sort of works – but….
it seems that it includes the first layer in all of the swf output files
So I have layers a,b,c,d in file test
testa.swf shows layer a
testb.swf shows layer a and b
testc.swf shows layer a and c
testd.swf shows layer a and d
It’s easy enough to fix by inserting a blank layer, but I thought I’d let you know!