views:

6

answers:

0

I need to export FLA as a sequence of PNG images using JSFL.

The first problem I faced is that I cannot call document.importPublishProfileString to change current publish profile, it always fails (returns 0). Now I create a separate publish profile, removing it if already exists. I don't know why it's not mentioned in the documentation.

The second problem is more severe. Publish profile is ignored when I call document.exportPNG(). Width and height which I last used in the dialog "File > Export > Export movie" are used instead. The profile is created with correct settings, I can see them using UI. Now even publishing through UI (File > Publish) uses settings from movie export.

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);

Is there any way to make exportPNG respect settings from the profile?