• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Change stroke size with JSFL?

Participant ,
Oct 22, 2020 Oct 22, 2020

Copy link to clipboard

Copied

Is it possible to use JSFL to select the Line tool from the Tools panel, and then set the "Stroke size" parameter (or any of those parameters in the Properties panel) to a certain value?

Views

245

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 22, 2020 Oct 22, 2020

Copy link to clipboard

Copied

See getCustomStroke()/setCustomStroke() in the JSFL docs.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 23, 2020 Oct 23, 2020

Copy link to clipboard

Copied

Beautiful! Thanks. i swear i had already tried that. 🙂

 

While we're talking, i'm having trouble doing another thing... (perhaps i should make a new post?)

 

i draw some stuff on a layer. i want this to happen:

  • select everything on the layer i've just drawn on
  • change that layer to 50% alpha

 

i can't get it to work, because i can't figure out how to indicate the most recently drawn-on layer. My script will work if i click on the layer in the timeline, but i don't want to have to do that. And document.selectAll() grabs everything on all layers. i tried a goofy workaround, by locking all other layers before i selectAll(), but even that doesn't work unless i've physically clicked to select the current layer in the timeline:

var dom = an.getDocumentDOM();
var tl = dom.getTimeline();
var layer = tl.layers[tl.currentLayer]; // perhaps a useless declaration, because locking is a method of Timeline, not Layer
// Lock all other layers:
tl.setLayerProperty("locked", true, "others");

If i draw on a layer and run this script, it locks ALL layers (instead of all OTHER layers) and i don't understand why. It won't work unless i first click to select the layer in the timeline.

- Ryan




Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 23, 2020 Oct 23, 2020

Copy link to clipboard

Copied

Hi,

I can't understand what you want to achieve with the code, but I would say that the method
timeline.setLayerProperty() works with "selected" layers, not the "current" one.
So, If you want to lock all layers, with the exceptance of one (or more), you need to select these layers:

var timeline = fl.getDocumentDOM().getTimeline();
timeline.setSelectedLayers(3);
timeline.setLayerProperty("locked", true, "others" );

Now, the parameters make sense:
"selected" - changes the selected layers
"others" - changes "unselected" layers
"all" - changes all layers




- Vlad: UX and graphic design, Flash user since 1998
Member of Flanimate Power Tools team - extensions for character animation

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 23, 2020 Oct 23, 2020

Copy link to clipboard

Copied

What i'd like to achieve is precisely this:

 

1. Draw some lines on a layer.

2. Use a keyboard shortcut to run a JSFL script.

3. All of the artwork (ONLY on the layer i was just drawing on) is automatically selected.

4. Convert lines to fills.

5. The layer is set to 50% transparency.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 23, 2020 Oct 23, 2020

Copy link to clipboard

Copied

LATEST

OK, I see 🙂

Save the following code as a command, assign it a shortcut key and press the button each time after finish your drawing on the layer.
I think, it should work as you expect.

 

var doc = fl.getDocumentDOM();
var tml = doc.getTimeline();
var myLayer = tml.layers[ tml.currentLayer ];
var myFrame = myLayer.frames[ tml.currentFrame ];


// Deselect all
// After that iterate through the elements in the current frame of the current layer
doc.selectNone()
for( var i = 0; i < myFrame.elements.length; i++ ){
  myFrame.elements[ i ].selected = true;
}

// Convert lines to fills.
doc.convertLinesToFills();

// The layer is set to 50% transparency.
myLayer.transparent = true;
myLayer.alpha = 50;

 

 

 

- Vlad: UX and graphic design, Flash user since 1998
Member of Flanimate Power Tools team - extensions for character animation

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines