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

1k views Asked by At

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.

3

There are 3 answers

0
Justin Putney On BEST ANSWER

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();
0
Ibis Fernandez On

Actually you can set the value to "null" and it will set the color to no color.

0
Juraj On

It seems that setCustomStroke(mystroke) sets stroke to none only when mystroke.style="solid" and there are no other properties. You don't have to get mystroke using getCustomStroke. It can be generic object with only one attribute style set to solid.

var mystroke=new Object();
mystroke.style="solid";
fl.getDocumentDOM().setCustomStroke(mystroke);