Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Money counter w/ a non-liner counting progression

  • Money counter w/ a non-liner counting progression

    Posted by Jim Dodson on June 4, 2009 at 5:34 pm

    I am using Dan’s elegant expression to countdown currency (I added the dollar sign down there between the two quotes — (I’m guessing that’s why you put the quotes there, Dan? — anyway it workes great.)

    Anyway, my question is there a way to slow the countdown down as it gets into the lower digits? Right now it is a linear progression based on time and duration — so when I’m counting down from 1,000.000 when it gets to $10,000 it just basically clicks to $0.00… I’d like an easy-ease type slow down that I can control somehow…

    YOU GUYS ROCK ON THIS FORUM, by the way!!

    startValue = 7000;
    endValue = 13000;
    dur = 30; //seconds

    s = “” + Math.round(linear(time,0,dur,startValue,endValue));
    s.substr(0,s.length-3) + “,” + s.substr(-3,3)

    Jim Dodson

    8 Core Intel — Mac – OSX

    Ernesto Sanchez replied 11 years, 8 months ago 4 Members · 17 Replies
  • 17 Replies
  • Jim Dodson

    June 4, 2009 at 6:08 pm

    Oh the ecstasy!!!!

    Works perfectly — thank you!!!!!

    Jim Dodson

    8 Core Intel — Mac – OSX

  • Dan Ebberts

    June 4, 2009 at 6:11 pm

    I think the easiest might just be to keyframe a slider the way you want the value to vary over time and use this expression:

    slider = effect(“Slider Control”)(“Slider”);

    numDecimals = 0;
    commas = true;
    dollarSign = true;

    s = 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

  • Jim Dodson

    June 4, 2009 at 11:29 pm

    Is there any way to use this with 1 (or 2) decimal places (prefer one decimal place.)
    So I can start at $39 and go down to $3.5 (it’ll say $3.5 Million — but i think I can add the “million”)

    Jim Dodson

    8 Core Intel — Mac – OSX

  • Dan Ebberts

    June 5, 2009 at 2:09 am

    Try changing the second line to this:

    numDecimals = 1;

    Dan

  • Dustin Ward

    May 24, 2011 at 10:26 pm

    This is great. Is there a way to get it to $10,000,000 and beyond?

  • Dan Ebberts

    May 24, 2011 at 10:39 pm

    How accurate do you need it to be? You could just keyframe the slider to 1,000,000 and change the first line of the expression to this:

    slider = effect(“Slider Control”)(“Slider”)*10;

    Dan

  • Dustin Ward

    May 24, 2011 at 11:00 pm

    I guess I should explain my project a little better. I am trying to get the counter to go really fast up to around $9,900,000 and slowly slow down from there to $10,000,000. I want it to rest on $10,000,000 for a few seconds and then slowly begin to count again. It needs to be accurate down to the penny. I’m not sure what the exact amount is just yet. Lets say it needs to land on $10,156,523.22

  • Dan Ebberts

    May 24, 2011 at 11:24 pm

    Instead of a slider control, you might try an angle control. I just tried it and it goes up to at least 1,000,000,000,000. It’s a little funky to enter big numbers into (I’d zero out the revolutions and enter the entire number in the degrees field), but if you don’t have a lot of keyframes, I don’t see why it wouldn’t work.

    Dan

  • Dustin Ward

    May 25, 2011 at 12:02 am

    That worked perfectly.. now how do I get my cents?

  • Dan Ebberts

    May 25, 2011 at 12:06 am

    What do you have numDecimals set to? It should be 2:

    numDecimals = 2;

    Dan

Page 1 of 2

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