3 Replies Latest reply on Dec 8, 2006 8:01 PM by abeall

    Fireworks Automation: Applying a Stroke (Brush) to a Path That Doesn't Have One

    billgregg
      I've tried setting various brush properties to apply a stroke to an existing path that doesn't have one, but so far nothing works. My code looks like this (it's contained within a while loop):

      currentselection[0].pathAttributes.brush.feedback="brush"

      or:

      currentselection[0].pathAttributes.brush.diameter=1

      Everything I've tried produces an error. Can anyone point me in the right direction?

      Bill Gregg
        • 1. Re: Fireworks Automation: Applying a Stroke (Brush) to a Path That Doesn't Have One
          abeall Level 3
          I haven't done much with strokes, but you might have to use the various dom.setBrush commands. Some properties can be changed directly in the FW API, but quite a few cannot and must be changed with the appropriate dom commands to set them. What error does it give?

          Something like this might be what you want:

          var oldSelection = new Array().concat(fw.selection); // save the old selection
          fw.selection = [currentselection[0]];
          dom.setBrush(...);
          fw.selection = oldSelection;

          HTH

          btw, did you ever get the problem you brought up in thread 1218856 resolved?
          • 2. Re: Fireworks Automation: Applying a Stroke (Brush) to a Path That Doesn't Have One
            billgregg Level 1
            Thanks for the suggestion. I think I've solved my problem using the setBrushNColor method.

            I'm relying heavily on the sample scripts that accompany Fireworks. I've put 'em all into one text file and I search it. And sometimes I google a method or property name and see what turns up (usually not much). So if I can't turn up a specific example of how a method is used, sometimes I can't figure out how to use it. I think I tried using setBrush, but couldn't get the parameters right. So finally I fell back on using the "Copy Steps" command in the history palette. Using that, I got:

            fw.getDocumentDOM().setBrushNColor({alphaRemap:"none", angle:0, antiAliased:true, aspect:100, blackness:0, category:"bc_Pencil", concentration:100, dashOffSize1:2, dashOffSize2:2, dashOffSize3:2, dashOnSize1:8, dashOnSize2:1, dashOnSize3:1, diameter:1, feedback:"brush", flowRate:0, maxCount:15, minSize:1, name:"bn_1-Pixel Anti-Aliased", numDashes:0, shape:"circle", softenMode:"bell curve", softness:0, spacing:15, textureBlend:0, textureEdge:0, tipColoringMode:"random", tipCount:1, tipSpacing:0, tipSpacingMode:"random", type:"simple" }, "#000000");

            Apparently none of the parameters are optional--it gives an error if I try to pare down the list. Not very elegant, but it gets the job done.

            And after a while I figured out that some of the commands I wanted to use could not be targeted to anything but the selection, so I've started filling arrays with lists of items I want to change, then applying the command--just like you're doing in the sample you sent. That technique is working well so far.

            As for the multiple-paragraph text boxes, I've just kicked that problem down the road a bit. I realized that that in the files we'll be dealing with, there probably won't be that many multiple-paragraph text boxes. I'll have to work on it eventually, but it's dropped down the to-do list for now. Thanks for the suggestion--it'll be my starting point when I get back to that problem.

            What kinds of things are you trying to do with JavaScript in Fireworks?

            Bill Gregg
            • 3. Re: Fireworks Automation: Applying a Stroke (Brush) to a Path That Doesn't Have One
              abeall Level 3
              Sounds like you're on the right track in your workflow as far as I know how. Copy Steps in the History panel is often how I start a command, or find dom functions I'm looking for. Also I pretty much always have the livedocs open when working:
              http://livedocs.macromedia.com/fireworks/8/fwextending/wwhelp/wwhimpl/js/html/wwhelp.htm
              Another very useful extension for Dreamweaver when creating Fireworks .jsf files:
              http://senocular.com/dreamweaver/extensions.php?id=0.1

              > What kinds of things are you trying to do with JavaScript in Fireworks?
              I just started using the JS API myself. I've made a few commands and panels to help in my work, mostly. The possibilities seem nearly limitless, though.