Search code examples
flashflash-cs4jsfl

JSFL setCustomStroke does not work with stroke.style = "noStroke"


So I was messing around with JSFL, and I wanted to set the storke to None. That should be done like this:

var stroke = fl.getDocumentDOM().getCustomStroke("toolbar");
stroke.style = "noStroke";
fl.getDocumentDOM().setCustomStroke(stroke);

But that does NOT work.

Doing the corresponding thing with fills work! (I've had NO trouble with fills at all!)

If I manually set the storke to "None" in the toolbar (using the color-picker), and then execute this:

var stroke = fl.getDocumentDOM().getCustomStroke("toolbar");
stroke.style = "solid";
stroke.color = "#0066ff";
fl.getDocumentDOM().setCustomStroke(stroke);

I get a solid storke with aRGB value: 00 00 00 00 (0 alpha, 0 red, 0 green, 0 blue). (Which normally is impossible using the color-toolbar)

If I execute that command once more, I get the right stroke color! (It also works if I have any normal solid color. If the stroke is a gradient or bitmap, nothing happens).

As I mentioned, there have been NO problems at all with setting things for fills. ONLY strokes.


Solution

  • I've also encountered this bug that doesn't allow you to set "noStroke." I have found a workaround, though. Swap the stroke and fill, then set the fill to "noFill" and swap back. Like so:

    var dom = fl.getDocumentDOM();
    dom.swapStrokeAndFill();
    var tempFill = dom.getCustomFill("toolbar");
    tempFill.style = "noFill";
    dom.setCustomFill(tempFill);
    dom.swapStrokeAndFill();