Skip to main content
Jhon5C3C
Participant
Aug 11, 2021 8:34 PM UTC
Answered

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

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 is closed to new replies. Start a new post to keep the conversation going.
    JoãoCésar17023019
    JoãoCésar17023019Correct answer
    Community Expert
    Aug 12, 2021 1:31 PM UTC

    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

    2 replies

    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    Aug 12, 2021 1:31 PM UTC

    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

    Translate
    Jhon5C3C
    Jhon5C3CAuthor
    Participant
    Aug 12, 2021 9:38 PM UTC

    Thanks, it's working!

    Translate