1 Reply Latest reply on Jan 16, 2014 11:19 AM by sinious

    Can't change publish profile programatically

    Enzo1234

      I'm trying to publish several files consecutively using a Flash javascript script. However, I seem to be having problem changing the publish profile. This simple code doesn't work as it should:

       

      var doc = fl.openDocument('file:///******/*****/Documents/Shared/1218_DOL_week2_LTP_35p_21h.fla');

      var oldPublishProfile = doc.exportPublishProfileString('Default');


      var newPublishProfile = oldPublishProfile.replace(

                /<flashFileName>.*<\/flashFileName>/,

                "<flashFileName>" + 'Random Test File' + "</flashFileName>"

      );


      fl.trace(newPublishProfile); // Prints the modified publish profile


      doc.importPublishProfileString(newPublishProfile);


      fl.trace(doc.exportPublishProfileString()); // Should print the same modified publish profile, but it actually prints the old one.

       

      Moreover, the script that I'm trying to use worked yesterday. Today when I tried it again, without doing any modifications to it, it didn't work. I'm not sure if the problem is my system or if there's some flash configuration I'm unaware of.

       

      Any help will be greatly appreciated, because I've been a long time trying to figure out what's going on.

       

      Thank you very much.

       


        • 1. Re: Can't change publish profile programatically
          sinious Most Valuable Participant

          I can confirm that this is not working Flash CS5.5, CS6 or CC.

           

          In CC the trace is the same as you're getting. The first trace shows the replacement worked fine, the trace of the documents publish settings however do not contain the change.

           

          I tried even changing it so it replaced all filenames (and included the extension) incase that was an invalid setting, forcing Flash to discard the import, but it still doesn't overwrite the import:

           

          var newPublishProfile = oldPublishProfile.toString().replace(

                    /\<(.*)?FileName\>.*?\.(.+?)\</g,

                    "<$1FileName>TestFile.$2<"

          );

           

          Traces:

           

              <flashFileName>TestFile.swf</flashFileName>

              <projectorWinFileName>TestFile.exe</projectorWinFileName>

              <projectorMacFileName>TestFile.app</projectorMacFileName>

              <htmlFileName>TestFile.html</htmlFileName>

              <gifFileName>TestFile.gif</gifFileName>

              <jpegFileName>TestFile.jpg</jpegFileName>

              <pngFileName>TestFile.png</pngFileName>

              <svgFileName>TestFile.svg</svgFileName>

              <rnwkFileName>TestFile.smil</rnwkFileName>

              <swcFileName>TestFile.swc</swcFileName>

           

          Yet fails on the second trace as well. Even if I copy the string returned from the old publish profile and supply it (with the names changed) as a string without running a RegExp on it, the import has no effect, so it can't be a structure issue.

          1 person found this helpful