Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Counter to billions with slider control

  • Counter to billions with slider control

  • David Stark

    November 8, 2010 at 5:36 am

    I need to build a counter that will reach 102,456,367,670. In looking on the web I ran across Dan’s expression;

    val = effect(“Slider Control”)(“Slider”);
    numDec = 0; // digits to right of decimal
    numDigit = 2; // digits to left of decimal
    if (val < 0) sign = “-” else sign = “”; s = Math.abs(val).toFixed(numDec); while (s.length < numDigit + numDec + 1) s = “0” + s; sign + s

    I’m a novice at expressions but it appears that the slider effect will only allow me to go to 1,000,000. I like the idea of the slider because I want to keyframe the counter to the VO. Any suggestions?

    I’d also like to display the number with commas.

    Appreciate all the help.

    David.

  • Chris Wright

    November 8, 2010 at 6:13 am

    102 billion is a big number so I don’t think anyone will notice if you do slider*10 or something. Another way is use a counting code.

    have a source text, add timewarp whole frames to and then pickwhip its speed to slider. the text will count as fast as the length of the layer, then the timewarp whole frames will be keyframed.

    the text box source would be
    //
    numDecimals = 0;
    commas = true;
    dollarSign = false;
    beginCount = 0;
    endCount = 102456367670;
    dur = Math.floor(thisLayer.outPoint-thisLayer.inPoint);

    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;
    }

    https://technicolorsoftware.hostzi.com/

  • Filip Vandueren

    November 8, 2010 at 11:02 am

    Quick Fix:

    use an Angle control instead of a Slider control.
    It doesn’t seem to have the limitation.

    However, it doesn’t present it’s value as a straight up number, but revolutions + degrees

    102,456,367,670 becomes 284601021 x + 110°

    but you can just enter 0 revolutions and 102456367670 in the degrees box and it will figure this out for you

  • Nick Vaka

    July 27, 2015 at 1:42 pm

    Hey! This works perfectly for me and counting up to 2,000,000,000. My big question would be if there was a way to start this with 10 zeroes instead of counting up all the digits? That would solve every problem I’ve got… with regards to this project at least ;p.

    Thanks!

    Nick

    Nick Vaka
    Motion Graphics & Animation
    https://www.nickvaka.com

Viewing 1 - 4 of 4 posts

Log in to reply.

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