Flash CS4,JSFL:更改exportPNG的设置
我需要使用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尊重设置?
我认为PNG发布设置实际上是指发布的SWF中的图像,不是JPG压缩的。
或者,如果您从SWF面板启动脚本,则可以使用发布设置导出SWF,检索它,将其加载到面板中,然后使用类似AS3CoreLib的方式生成每个帧的PNG。 由于您使用的是CS4,因此Flash Player 10应让您保存到本地驱动器。
我只是改变你的脚本,先关闭MatchMovieDim,然后再尝试设置宽度和高度,这对我很有用。 我认为宽度和高度设置被拒绝,直到MatchMovieDim关闭。
profile.PublishPNGProperties.MatchMovieDim = 0;
profile.PublishPNGProperties.Width = 500;
profile.PublishPNGProperties.Height = 500;
链接地址: http://www.djcxy.com/p/17769.html