Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Change Shape Layer Color Based on Source Text Value

  • Change Shape Layer Color Based on Source Text Value

    Posted by Adam Haas on August 14, 2018 at 5:36 pm

    I have a text layer that shows “Good” or “Bad” based on another layer.

    I have a shape layer that is behind that text, and I want the color to change to red if the text says “Bad” and green if the text says “Good”.

    I thought this would be pretty simple, but an if statement on the color attribute of the shape layer doesn’t seem to be working.

    Adam Haas replied 7 years, 8 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    August 14, 2018 at 5:51 pm

    Something like this, probably:


    txt = thisComp.layer("text").text.sourceText;
    if (txt == "Good")
    [0,1,0,1]
    else if (txt == "Bad")
    [1,0,0,1]
    else
    value

    Dan

  • Adam Haas

    August 14, 2018 at 5:58 pm

    Well, it’s kind of working. I see the colors change, however when I try to set to a specific color, it just ignores it:


    txt = thisComp.layer("text").text.sourceText;
    if (txt == "Good")
    [121,193,143,1]
    else if (txt == "Bad")
    [189,80,80,1]
    else
    value

  • Dan Ebberts

    August 14, 2018 at 6:00 pm

    The colors have to be normalized (between 0 and 1):


    txt = thisComp.layer("text").text.sourceText;
    if (txt == "Good")
    [121,193,143,255]/255
    else if (txt == "Bad")
    [189,80,80,255]/255
    else
    value

    Dan

  • Adam Haas

    August 14, 2018 at 6:05 pm

    That did the trick! Thank you so much.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy