问题
I found this script which seems to do what I need, however, when I try to export a file I get the "filename: false" as output. Any idea?
http://cookbooks.adobe.com/post_Extract_bitmaps_and_audio_from_a_FLA_file-18144.html
回答1:
Took me a bit but I figured out your problem. The issue is with this little property of your sound file: soundItem.originalCompressionType
. You can find some detail for the issue here. What is happening in your code is that it will try to export the sound file as the type that it is stored as in the library. i.e. filename.mp3 saves as a .mp3 file and filename.wav saves as a .wav file. If the soundItem.originalCompressionType
is equal to "RAW" you cannot save the sound file as a .mp3 file, thus the "filename: false" output. You must save the file as a .wav file. I modified the code a tiny bit when defining the imageFileURL to do this.
// 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);
}
}
来源:https://stackoverflow.com/questions/11909053/is-it-possible-to-use-jsfl-to-export-sound-files-from-flash-library