Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions change color to array desired words

  • change color to array desired words

    Posted by Peter Zeet on April 5, 2017 at 12:08 am

    Hi!
    Is there an easy way to make a text color fill selector work only when certain numbers (or words) within an array are reached?

    I have an expression on the source text to add “.” on thousands plus the extra + “$”, linked to a slider, so I need to have certain values highlighted, like for example

    my array=(“1.245.345 $”, “348.154 $”,”987.348 $”)

    thanks!

    Peter Zeet replied 9 years, 3 months ago 2 Members · 7 Replies
  • 7 Replies
  • Dan Ebberts

    April 5, 2017 at 3:57 am

    Something like this for the Amount property of the selector maybe:


    myArray=["1.245.345 $", "348.154 $","987.348 $"];
    txt = text.sourceText;
    gotOne = false;
    for (i = 0; i < myArray.length; i++){
    if (txt == myArray[i]){
    gotOne = true;
    break;
    }
    }
    gotOne ? 100 : 0

    Dan

  • Peter Zeet

    April 5, 2017 at 6:29 pm

    works perfect, thank you!!

  • Peter Zeet

    April 6, 2017 at 2:04 pm

    a quick variation… how it would be adding a fade instead of the 100 value?
    I’m doing a linear(time,0,.2,100,0), but it does nothing.
    I think I should define time ?

  • Dan Ebberts

    April 6, 2017 at 5:28 pm

    To make it fade, the expression would need to know how long it has been since the current number changed to its current value. What’s driving the changes in the source text?

  • Peter Zeet

    April 6, 2017 at 5:44 pm

    it’s a keyframed slider (with just 2 frames, one with value 0 and other with 100, which drives the final amount, but the place where the last keyframe is may vary)

    I have this expression at the text source:

    countTotal=3782721;
    textBefore = "+";
    textAfter = " $";
    s=thisComp.layer("control").effect("grow")("Slider");
    n="" + Math.round(s*countTotal/100);
    s="";
    for(i=0, l=n.length; i

  • Dan Ebberts

    April 6, 2017 at 8:07 pm

    That makes things considerably more complicated. One solution would be to insert another loop, inside the loop that’s checking each array element, to go back, frame-by-frame, from the current time to see if that array element shows up within the past .25 seconds (or whatever your ramp time is) and calculate how long ago that was, and use that to drive your linear() or ease() ramp.

    Dan

  • Peter Zeet

    April 6, 2017 at 8:42 pm

    uhm! yes, it gets quite complicated! thanks for the tip!!

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