是否可以使用jsfl从Flash库导出声音文件? [英] Is it possible to use jsfl to export sound files from flash library?

查看:215
本文介绍了是否可以使用jsfl从Flash库导出声音文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现这个脚本似乎做了我所需要的,但是当我尝试导出一个文件时,我得到filename:false作为输出。任何想法?

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

推荐答案

让我有点不过我想出了你的问题。问题是您的声音文件的这个小属性: soundItem.originalCompressionType 您可以在这里找到一些问题的细节。代码中发生的是它会尝试将声音文件导出为存储在库中的类型。即filename.mp3保存为.mp3文件,filename.wav保存为.wav文件。如果 soundItem.originalCompressionType 等于RAW,则无法将声音文件保存为.mp3文件,因此filename:false输出。您必须将该文件保存为.wav文件。在定义imageFileURL时,我修改了一些代码。

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

这篇关于是否可以使用jsfl从Flash库导出声音文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆