我需要使用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尊重设置?
发布于 2011-02-26 11:46:44
我认为PNG发布设置实际上指的是发布的SWF中非JPG压缩的图像。
或者,如果从SWF面板启动脚本,则可以使用发布设置导出SWF,检索它,将其加载到面板中,然后使用类似AS3CoreLib的内容生成每个帧的PNG。既然你是在CS4中,Flash player10应该可以让你保存到本地驱动器。
发布于 2012-03-19 14:28:14
我刚刚修改了你的脚本,在尝试设置宽度和高度之前,首先关闭了MatchMovieDim,它对我很有效。我认为宽度和高度设置会被拒绝,直到MatchMovieDim关闭。
profile.PublishPNGProperties.MatchMovieDim = 0;
profile.PublishPNGProperties.Width = 500;
profile.PublishPNGProperties.Height = 500;https://stackoverflow.com/questions/4060734
复制相似问题