CS5.5 JSFL dynamic publish settings

It seems like I’m only one of the very few people in the world who actually use JSFL for their projects, because Google just can’t find anything on it.Ā  For those of you who are looking to use JSFL to dynamically change their publish settings so they can for example make a version with “Omit Trace Actions” and one without.Ā  Or better yet, different config constant settings here is a good example:

var doc=fl.getDocumentDOM();
var profile;
var flashFileName;
 
//Delete a prev attempted temp profile
if (doc.publishProfiles.indexOf('@temp') != -1) {
  doc.currentPublishProfile = '@temp';
  doc.deletePublishProfile();
}
 
//Make a copy of the 1st profile and tweak
doc.currentPublishProfile=doc.publishProfiles[0]; 
profile=new XML(doc.exportPublishProfileString());
flashFileName=profile.PublishFormatProperties.flashFileName.split('.').shift();
doc.addNewPublishProfile('@temp');
doc.currentPublishProfile='@temp';
profile.@name="@temp";
profile.PublishFormatProperties.projectorWin=1; 
profile.PublishFormatProperties.OmitTraceActions=0; 
profile.PublishFormatProperties.flash=1;
profile.PublishFormatProperties.flashDefaultName=0;
profile.PublishFormatProperties.flashFileName=flashFileName+'2.swf';
profile.PublishFlashProperties.Report='0';
profile.PublishFlashProperties.Quality='80';
profile.PublishFlashProperties.DebuggingPermitted=1; //Need debugging
profile.PublishFlashProperties.AS3ConfigConst=<AS3ConfigConst>DEBUG::translator="false";APP::externalMp3="false";DEBUG::reels="false";APP::isIntegrated="false";APP::urlParams="";</AS3ConfigConst>
doc.importPublishProfileString(profile);
 
//Publish it now and delete the temp profile
doc.publish();
doc.deletePublishProfile();

Pay special attention to “AS3ConfigConst” because you can’t just set it directly. You must re-enclose it in XML. It took me almost a day to figure that out, cause no one else in the inter-web-nets has gone this far. So your welcome the handful of you adventurous JSFL programmers. Please comment so I know you exist šŸ™‚

4 comments

  1. Maspuce says:

    Thanks you saved me sooo much time. I have combined this script with gskinner’s compileProject.jsfl so I can easy have a release version of my project, I have have a small problem though.
    The OmitTraceActions and DebuggingPermitted properties don’t seem to be working? Do you have any ideas on what the problem can be?

  2. Evan Gifford says:

    For OmitTraceActions, it was targeting incorrect node “PublishFormatProperties”, you can fix by targeting “PublishFlashProperties” node. šŸ™‚

  3. T says:

    CS4 and CS5 might have some differences. Try the PDF docs for JSFL to find out more. http://help.adobe.com/en_US/flash/cs/extend/flash_cs5_extending.pdf

  4. Damian D says:

    To anyone who is trying to change the Flash Player Version(Target). For FP 9 and below you will need to reset the ExternalPlayer variable to an empty string. And for players above 9 you need to set the ExternalPlayer variable to the correct value or otherwise it will not work.

    Example set flash player 9:
    profile.PublishFlashProperties.Version= 9;
    profile.PublishFlashProperties.ExternalPlayer = ”;

    Example set ver. 10.3:
    profile.PublishFlashProperties.Version= 13;
    profile.PublishFlashProperties.ExternalPlayer = ‘FlashPlayer10.3’;