0

I just wondering if there a way to optimize the way of changing color of numbers in stock exchange template by using expressions? When I put the +before the number it turns green and if -,it turns red.

1 Answer 1

0

This is probably not the shortest way of doing it, but it's quick and easy:

  1. Make a null layer with a slider
  2. Make a text layer with green text
  3. Link the source text in your text layer to the slider in the null layer.

You should see an expression like this:

thisComp.layer("slider null").effect("Slider Control")("Slider")

Now add an expression to the Opacity control in your text layer. This is going to make the Opacity go to 0 if the slider value is below zero, or 100 if it is zero or above:

if(thisComp.layer("slider null").effect("Slider Control")("Slider")>=0) {100} else {0};
  1. Now duplicate the green text layer

  2. Rename it "red text"

  3. Change the text colour to red

  4. Edit the expression on the red text layer's Opacity control to this:

    if(thisComp.layer("slider null").effect("Slider Control")("Slider")<0) {100} else {0};

Now the red text layer should only be visible when the slider value is lower than zero.

Screenshot of the whole thing below: screen shot

If you want a leading "+" before the positive values, you could also make an "if/else" statement in the green Source text control, so you only see a "+" when the value is above zero - something like this:

if(thisComp.layer("slider null").effect("Slider Control")("Slider")>0) {"+" + thisComp.layer("slider null").effect("Slider Control")("Slider")} else {thisComp.layer("slider null").effect("Slider Control")("Slider")};
2
  • Hi! Very interesting and not obvious solution. Thank you! Dec 19, 2020 at 15:50
  • please mark as answered!
    – tomh
    Dec 19, 2020 at 20:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.