简体   繁体   English

有没有办法通过 JSFL 脚本请求当前在 Adobe Flash/Animate 中打开的 FLA 文件的文件位置?

[英]Is there a way to request the file location of the currently in Adobe Flash/Animate opened FLA file through a JSFL script?

First of all, I'm not a JavaScript or Flash pro at all.首先,我根本不是 JavaScript 或 Flash 专业人士。 But I have this JSFL script file to extract audios and bitmaps from FLA files through Adobe Flash/Animate.但是我有这个 JSFL 脚本文件,可以通过 Adobe Flash/Animate 从 FLA 文件中提取音频和位图。 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.") ).我想用相当多的 FLA 文件来做这件事,但是在这个过程中有一个部分使它比理想的更耗时,这是脚本要求我 go 到目标文件夹的部分( 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.打开的 Windows Explorer window 类型是小型的,您不能将整个地址粘贴到地址栏中,当您必须通过许多文件夹访问 go 时,这很乏味。

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.当我用文件夹 URL 替换browseForFolderURL("Select a folder.")时,它变得不那么烦人了,但我显然每次都必须为每个 FLA 文件更改它。 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.理想情况下,我会将脚本的这一部分替换为可以读取/检测我当前在 Adobe Flash/Animate 中打开的 FLA 文件位置的内容,我从中提取这些文件。 Does something like that exist?存在这样的东西吗?

For reference, here is the full JSFL code.作为参考,这里是完整的 JSFL 代码。

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

I suppose you can use:我想你可以使用:

document.path

Read-only;只读; a string that represents the path of the document, in a platform-specific format.表示文档路径的字符串,采用特定于平台的格式。 https://www.adobe.io/apis/creativecloud/animate/docs.html#.AdobeDocs/developers-animatesdk-docs/master/Document_object/docum190.md https://www.adobe.io/apis/creativecloud/animate/docs.html#.AdobeDocs/developers-animatesdk-docs/master/Document_object/docum190.md

Or或者

document.pathURI

Read-only;只读; a string that represents the path of the document, expressed as a file:/// URI.表示文档路径的字符串,表示为 file:/// URI。 https://www.adobe.io/apis/creativecloud/animate/docs.html#.AdobeDocs/developers-animatesdk-docs/master/Document_object/docum200.md https://www.adobe.io/apis/creativecloud/animate/docs.html#.AdobeDocs/developers-animatesdk-docs/master/Document_object/docum200.md

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM