0 Replies Latest reply on Jun 2, 2012 8:25 PM by groove25

    FW Scripting: Does saveSelection() require documentIndex or not?

    groove25 Level 4

      Hey, Fireworks users! If you're into scripting at all, please try the following test. First, copy this simple script and place it into a .jsf file or into the Command Prompt panel, or anything that allows you to run a script within Fireworks:

       

           fw.getDocumentDOM().saveSelection("test-123", "new or replace");

           fw.getDocumentDOM().setSelectionMask(null,"replace");

           fw.getDocumentDOM().restoreSelection("test-123");

       

      Now create or open two FW documents, and make a quick bitmap selection within the second document, using the Magic Wand, Marquee tool, or what-have-you. Now run the script.

       

      simple test.png

       

      Ideally, nothing will seem to have happened. This script is designed to save an active bitmap selection, to remove it, and then to restore it—all within the active FW document. If you check in the Restore Selection dialog, you should see the file "test-123" listed among the saved selections. Otherwise, everything will be the same.

       

      At least that's what's supposed to happen. What you may get instead is an error message, like this one:

       

      saveSelection error message.png

       

      If that's the case, replace the previous script with this version... Are the results any better? (They should be.)

       

           fw.getDocumentDOM().saveSelection("test", 1, "new or replace");

           fw.getDocumentDOM().setSelectionMask(null,"replace");

           fw.getDocumentDOM().restoreSelection("test");

       

      What's missing from the first version of the script is a documentIndex ("1") within the saveSelection() function. According to the "Extending Fireworks" PDF resources for both FW8 and CS5, this argument is NOT required, and if it is omitted, the active document will be asssumed. But that's not what happens. Instead, saveSelection() assumes the bottom-most document [0] and mis-saves the selection in that document instead of the active one. As a result, when restoreSelection() looks for the selection within the active document, it cannot find it.

       

      This bug was observed in FW8, and a bug report was recently filed with Adobe. However, if you've replicated the bug in a more recent version of FW, please consider sending an additional bug report to Adobe, referencing your own version:

       

      https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform

       

      Instead of a writing out your own description, feel free to include a link to this discussion in your bug report. Also, if your version of FW does NOT exhibit this bug, please leave a comment below. Thanks!

       

      FOLLOW-UP: This bug remains in Fireworks CS5.1 and CS6 on Mac OS 10.6.8 (Snow Leopard).saveSelection bug CS6.png