Skip to main content
Inspiring
October 23, 2020
Question

Change stroke size with JSFL?

  • October 23, 2020
  • 1 reply
  • 693 views

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?

    This topic has been closed for replies.

    1 reply

    Legend
    October 23, 2020

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

    Inspiring
    October 23, 2020

    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




    Vladin M. Mitov
    Inspiring
    October 23, 2020

    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 1998Member of Flanimate Power Tools team - extensions for character animation