JSFLを使用してFLAを一連のPNG画像としてエクスポートする必要があります。
私が直面した最初の問題は、document.importPublishProfileStringを呼び出して現在の公開プロファイルを変更できないことです。これは常に失敗します(0を返します)。次に、別の公開プロファイルを作成し、すでに存在する場合は削除します。ドキュメントに記載されていない理由がわかりません。
2番目の問題はより深刻です。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が設定を尊重するようにする方法はありますか?