First of all, I'm not a JavaScript or Flash pro at all. But I have this JSFL script file to extract audios and bitmaps from FLA files through Adobe Flash/Animate. I want to do this with quite some FLA files, but there's one part in the process that makes it more time-consuming than ideal, which is the part where the script asks me to go to the destination folder (browseForFolderURL("Select a folder.")
). The type of Windows Explorer window that opens, is the little one where you cannot just paste the whole address in an address bar, which is tedious when you have to go through many folders.
It gets less annoying when I replace browseForFolderURL("Select a folder.")
with the folder URL, but I obviously would have to change that for each FLA file each time. Ideally, I would replace this part of the script with something that can read/detect the location of the FLA file I have currently opened in Adobe Flash/Animate from which I am extracting those files. Does something like that exist?
For reference, here is the full JSFL code.
// Result of attempts to export will go to the output panel,
// so clear that first fl.outputPanel.clear();
// If bitmaps/audio in the library have been selected, export only
// those. Otherwise, export all bitmaps/audio in the library.
var lib;
if (fl.getDocumentDOM().library.getSelectedItems().length > 0) {
lib = fl.getDocumentDOM().library.getSelectedItems();
} else { lib = fl.getDocumentDOM().library.items; }
// Get destination directory for files
var imageFileURLBase = fl.browseForFolderURL("Select a folder.");
var imageFileURL;
var totalItems = lib.length;
// Iterate through items and save bitmaps and
// audio files to the selected directory.
for (var i = 0; i < totalItems; i++)
{
var libItem = lib[i];
if (libItem.itemType == "bitmap" || libItem.itemType == "sound")
{
// Check the audio files original Compression Type if "RAW" export only as a .wav file
// Any other compression type then export as the libItem's name defines.
if(libItem.itemType == "sound" && libItem.originalCompressionType == "RAW")
{
wavName = libItem.name.split('.')[0]+'.wav';
imageFileURL = imageFileURLBase + "/" + wavName;
} else {
imageFileURL = imageFileURLBase + "/" + libItem.name;
}
var success = libItem.exportToFile(imageFileURL);
fl.trace(imageFileURL + ": " + success);
}
}```