Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions AE counting money

  • Posted by Martin Abe on September 26, 2010 at 12:03 pm

    I’m trying to create an counter that goes up into the millions with a leading dollar sign and comma separators. Is it possible to do this with one text layer and a bunch of expressions?

    Dan Ebberts replied 12 years, 7 months ago 3 Members · 6 Replies
  • 6 Replies
  • Dan Ebberts

    September 26, 2010 at 4:26 pm
  • Martin Abe

    September 26, 2010 at 6:57 pm

    Cool
    Thanks
    How would you go about modifying this to have a keyframed begin and end point?

    numDecimals = 2;
    commas = true;
    dollarSign = true;
    beginCount = -1999;
    endCount = 1999;
    dur = 4;

    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

    September 26, 2010 at 10:24 pm

    You mean like with a Slider Control?

    Like this:


    numDecimals = 2;
    commas = true;
    dollarSign = true;
    dur = 4;
    s = effect("Slider Control")("Slider").value.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

  • Martin Abe

    September 26, 2010 at 10:57 pm

    Dan that’s awesome!
    You’re so great at expressing yourself.
    I’ve always marveled at the amazing power of expressions but could never wrap my head around them. If I can’t pick whip it, I’m whipped.

    Thanks

  • Ashley Marinelli

    October 8, 2013 at 8:05 pm

    how do you make it so the money amount actually counts up mine is suck on $1,999

  • Dan Ebberts

    October 8, 2013 at 10:54 pm

    Are you saying it doesn’t count from -1999 to 1999 over 4 seconds?

    Which expression are you using?

    Dan

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