Skip to main content
Jhon5C3C
Participant
August 11, 2021
Answered

Change symbol's thickness (it's a line) with javascript

  • August 11, 2021
  • 1 reply
  • 239 views

Hi all! I am trying to create electrical diagrams with animate but I need to click on a line to change its color and thickness. The thickness can now be changed: red.shape.graphics._stroke.style = "# 710033"; But I need to increase the thickness of the line and I have not found anything about it. Some clue?

    This topic has been closed for replies.
    Correct answer JoãoCésar17023019

    Hi.

     

    First make sure that the symbol the shape belongs to is excluded from texture generation in the output. Symbols that are made up of a single shape should be exported as vector.

     

    Then supposing you have a symbol instance on the stage called rec and it only has a child that is a rectangle shape made up of fill and stroke, you could change the tickness of the stroke like this:

    this.rec.children[1].graphics._strokeStyle.width = 1;

     

    I hope this helps.

     

    Regards,

    JC

    1 reply

    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    August 12, 2021

    Hi.

     

    First make sure that the symbol the shape belongs to is excluded from texture generation in the output. Symbols that are made up of a single shape should be exported as vector.

     

    Then supposing you have a symbol instance on the stage called rec and it only has a child that is a rectangle shape made up of fill and stroke, you could change the tickness of the stroke like this:

    this.rec.children[1].graphics._strokeStyle.width = 1;

     

    I hope this helps.

     

    Regards,

    JC

    Jhon5C3C
    Jhon5C3CAuthor
    Participant
    August 12, 2021

    Thanks, it's working!