【问题标题】:Is it possible to use jsfl to export sound files from flash library?是否可以使用 jsfl 从 flash 库中导出声音文件?
【发布时间】:2012-08-08 04:36:18
【问题描述】:

我发现这个脚本似乎可以满足我的需要,但是,当我尝试导出文件时,我得到“文件名:假”作为输出。有什么想法吗?

http://cookbooks.adobe.com/post_Extract_bitmaps_and_audio_from_a_FLA_file-18144.html

【问题讨论】:

    标签: flash export jsfl


    【解决方案1】:

    花了我一点时间,但我发现了你的问题。问题在于您的声音文件的这个小属性:soundItem.originalCompressionTypeYou can find some detail for the issue here。您的代码中发生的情况是,它将尝试将声音文件导出为存储在库中的类型。即 filename.mp3 保存为 .mp3 文件,filename.wav 保存为 .wav 文件。如果soundItem.originalCompressionType 等于“RAW”,则无法将声音文件另存为 .mp3 文件,因此会输出“filename: false”。您必须将文件另存为 .wav 文件。在定义 imageFileURL 时,我稍微修改了代码。

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

    【讨论】:

      猜你喜欢
      • 2019-03-11
      • 2010-09-07
      • 2020-06-09
      • 1970-01-01
      • 1970-01-01
      • 2010-11-25
      • 1970-01-01
      • 2012-11-27
      • 2014-10-10
      相关资源
      最近更新 更多