首先,我根本不是 JavaScript 或 Flash 专业人士。但是我有这个 JSFL 脚本文件,可以通过 Adobe Flash/Animate 从 FLA 文件中提取音频和位图。我想用相当多的 FLA 文件来执行此操作,但在此过程中有一个部分使它比理想的更耗时,即脚本要求我转到目标文件夹 ( browseForFolderURL("Select a folder.")
) 的部分。打开的 Windows 资源管理器窗口类型很小,您不能只将整个地址粘贴到地址栏中,当您必须浏览多个文件夹时,这很乏味。
当我用文件夹 URL 替换时,它变得不那么烦人browseForFolderURL("Select a folder.")
了,但我显然每次都必须为每个 FLA 文件更改它。理想情况下,我会将脚本的这一部分替换为可以读取/检测我当前在 Adobe Flash/Animate 中打开的 FLA 文件位置的内容,我从中提取这些文件。存在这样的东西吗?
作为参考,这里是完整的 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);
}
}```