我需要使用 JSFL 将 FLA 导出为 PNG 图像序列。
我面临的第一个问题是我无法调用 document.importPublishProfileString 来更改当前的发布配置文件,它总是失败(返回 0)。现在我创建一个单独的发布配置文件,如果已经存在则将其删除。我不知道为什么文档中没有提到它。
第二个问题更严重。当我调用 document.exportPNG() 时,发布配置文件被忽略。使用我上次在“文件 > 导出 > 导出电影”对话框中使用的宽度和高度。配置文件是使用正确的设置创建的,我可以使用 UI 看到它们。现在,即使通过 UI(文件 > 发布)发布也使用电影导出中的设置。
fl.outputPanel.clear();
var doc = fl.getDocumentDOM();
var profile = new XML(doc.exportPublishProfileString());
profile.@name = 'Game';
profile.PublishFormatProperties.png = 1;
profile.PublishFormatProperties.flash = 0;
profile.PublishFormatProperties.generator = 0;
profile.PublishFormatProperties.projectorWin = 0;
profile.PublishFormatProperties.projectorMac = 0;
profile.PublishFormatProperties.html = 0;
profile.PublishFormatProperties.gif = 0;
profile.PublishFormatProperties.jpeg = 0;
profile.PublishFormatProperties.qt = 0;
profile.PublishFormatProperties.rnwk = 0;
profile.PublishPNGProperties.@enabled = 'true';
profile.PublishPNGProperties.Width = 500;
profile.PublishPNGProperties.Height = 500;
profile.PublishPNGProperties.Interlace = 0;
profile.PublishPNGProperties.Transparent = 1;
profile.PublishPNGProperties.Smooth = 1;
profile.PublishPNGProperties.DitherSolids = 0;
profile.PublishPNGProperties.RemoveGradients = 0;
profile.PublishPNGProperties.MatchMovieDim = 0;
profile.PublishPNGProperties.DitherOption = 'None';
profile.PublishPNGProperties.FilterOption = 'None';
profile.PublishPNGProperties.MatchMovieDim = 0;
profile.PublishPNGProperties.BitDepth = '24-bit with Alpha';
fl.trace(profile);
if (doc.publishProfiles.indexOf('Game') != -1) {
doc.currentPublishProfile = 'Game';
doc.deletePublishProfile();
}
doc.addNewPublishProfile('Game');
fl.trace(doc.importPublishProfileString(profile));
var exportFileName = doc.pathURI.replace(/%20/g, " ").replace(doc.name, "1/" + doc.name.replace(/\.fla$/, "") + ".png"); // temporary hack
fl.trace(exportFileName);
doc.exportPNG(exportFileName, true, false);
有没有办法让 exportPNG 尊重配置文件中的设置?