Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects Expressions › How to change the color of the first character only in a number counter?

  • How to change the color of the first character only in a number counter?

    Posted by Spencer Evans on July 5, 2016 at 6:08 pm

    I am trying to display a number counting up from $19,949 to $20,000. I have that part figured out, but I want the dollar sign to be a different color than the rest of the word. I found a helpful number counting expression which I have modified to my needs, however I am not sure how to make the dollar sign be a different color now that expressions are applied to the layer. I want the dollar sign to be RGB 56, 184, 179 and the rest of the text to be RGB 175, 206, 10. Any help would be appreciated.

    Here is the code I have so far:

    numDecimals = 0;
    commas = true;
    dollarSign = true;
    beginCount = 19949;
    endCount = 20000;
    dur = 2;

    t = time - inPoint;
    s = ease (t, 0, dur, beginCount, endCount).toFixed(numDecimals);

    prefix = "";
    if (s[0] == "-"){
    prefix = "-";
    s = s.substr(1);
    }
    if(dollarSign) prefix += "$";

    if (commas){
    decimals = "";
    if (numDecimals > 0){
    decimals = s.substr(-(numDecimals + 1));
    s = s.substr(0,s.length - (numDecimals + 1));
    }
    outStr = s.substr(-s.length, (s.length-1)%3 +1);
    for (i = Math.floor((s.length-1)/3); i > 0; i--){
    outStr += "," + s.substr(-i*3,3);
    }
    prefix + outStr + decimals;
    }else{
    prefix + s;
    }

    Dan Ebberts
    replied 10 years, 2 months ago
    2 Members · 1 Reply
  • 1 Reply
  • Dan Ebberts

    July 5, 2016 at 6:33 pm

    You should be able to do that just by adding a Fill Color Animator and dialing the End parameter down so that only the first character is colored.

    Dan

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