Tag Archives: wav

Extract sounds and images from FLA in Flash CC with JSFL

Recently I learned that Flash CC dropped the ability to export WAV files! Dumb move by Adobe in my opinion, but what’s done is done.

After some Googling, I discovered this post on stackoverflow that contains a JSFL script to enable extracting sounds or images from the library of an FLA. It’s a few years old at this point, but I can confirm it still works for sounds as of Flash Pro CC 2014. If anyone has a more modern solution I’m all ears, but I’ll repost the code here in case that link ever breaks:

// 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);
    }
}

You'll need to save this to a file with a .jsfl extension, select any number of sounds or images from the library, and then go to Commands > Run Command in Flash Pro and navigate to the file. It'll ask you for an output directory and save the selected items there. If you don't select items in the library beforehand, it'll export all sounds and images found in the library.

To get the command to show up in the commands menu, put the file here:

Windows 7: boot drive\Users\username\AppData\Local\Adobe\Flash CC\language\Configuration\Commands

Windows Vista: boot drive\Users\username\Local Settings\Application Data\Adobe\Flash CC\language\Configuration\Commands

Mac OS X: Macintosh HD/Users/userName/Library/Application Support/Adobe/Flash CC/language/Configuration/Commands

filesystem data from here