Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Number Count Up Expression

  • Number Count Up Expression

    Posted by Lisa Ruiz on September 2, 2009 at 6:55 pm

    I’m using an expression to have a dollar amount of text count up from $0 up to $175
    I do not need a decimal or change so I have taken that out. I do need a dollar sign.
    My question is…
    How can you tell the expression to use superscript for the dollar sign? While on the same topic, how would you tell the expression to use superscript for the change if you were to use a decimal?

    numDecimals = 0;
    commas = true;
    dollarSign = true;
    beginCount = 0;
    endCount = 175;
    dur = .8;

    t = time - inPoint;
    s = linear (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 16 years, 8 months ago
    2 Members · 1 Reply
  • 1 Reply
  • Dan Ebberts

    September 2, 2009 at 9:57 pm

    I think the short answer is that you can’t do it with a single text layer. Expression-generated text all gets the formatting of the first character of the text it’s replacing.

    There is an obscure way, using a character value animator, to change the values of the characters, rather than replace the text. It might work, but the expression is very complex. You might be better off finding a different way.

    Dan

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