0

我需要使用 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 尊重配置文件中的设置?

4

2 回答 2

0

在尝试设置宽度和高度之前,我刚刚更改了您的脚本以先关闭 MatchMovieDim,它对我有用。我认为 Width 和 Height 设置被拒绝,直到 MatchMovieDim 关闭。

profile.PublishPNGProperties.MatchMovieDim = 0;
profile.PublishPNGProperties.Width = 500;
profile.PublishPNGProperties.Height = 500;
于 2012-03-19T06:28:13.573 回答
0

我认为 PNG 发布设置实际上是指已发布的 SWF 中未经过 JPG 压缩的图像。

或者,如果您从 SWF 面板启动脚本,您可以使用发布设置来导出 SWF,检索它,将其加载到您的面板中,然后使用类似AS3CoreLib的东西生成每个帧的 PNG 。由于您使用的是 CS4,因此 Flash Player 10 应该可以让您保存到本地驱动器。

于 2011-02-26T03:46:43.573 回答