Creative Communities of the World Forums

The peer to peer support community for media production professionals.

  • Posted by Reuben Fink on October 16, 2007 at 10:18 pm

    I’m trying to create a simple looking number counter. It has to go from zero to 130,000 then back to 1,000. I tried using the number Effect but it taps out at 30,000 for some reason and I need to go higher. Does anyone have any ideas? If the answer is using expressions well I know very little of that so you’de have to break it down for me. I saw the odometer tutorial but this job doesn’t need anything that fancy. Just numbers changing in sequential order would be great. Thanks.

    – rube

    Lara Malas replied 6 years, 1 month ago 12 Members · 15 Replies
  • 15 Replies
  • Mike Clasby

    October 17, 2007 at 12:09 am

    Here’s a Dan expression that goes on Source Text, link below.

    1) Put any letter on the screen where you want it with the Text Tool, the font you want and the size you want for your counter.

    Add the following expression for Source Text (Copy the expression, Alt-Click the Source Text Stopwatch, Paste, click outside the box):

    numDecimals = 0;
    commas = true;
    dollarSign = false;
    beginCount = 0;
    endCount = 130000;
    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;
    }

    This will count from zero to 130,000 in four seconds (dur, line 6 in code above).

    To go from 130,000 back to 1000, first trim that first text layer (Alt }) then I’d duplicate the Text layer, slide it back until it takes over where the first text layer stops, then change the expression, line 4 to;

    beginCount = 130,000;

    and line 5 to:

    endCount = 1000;

    That should do it. Dan’s expression lives here for a complete explanation:

    https://www.motionscript.com/design-guide/counter.html

  • Reuben Fink

    October 17, 2007 at 3:25 am

    thanks much. I’ll try this out first thing tomorrow.

  • Reuben Fink

    October 17, 2007 at 3:51 pm

    Your suggestion worked perfect.
    Much thanks.

  • Troy Ruff

    March 27, 2010 at 6:48 pm

    Thank you thank you, I have been trying to figure out how to do this and with no suggests until now, it works beautifully . Thanks so much.

    Troy

    Troy Ruff

  • Jonny Hal

    December 8, 2011 at 4:48 am

    Thanks so much — really helped me out.

  • Leandro Sarmento da silva

    June 29, 2012 at 8:22 pm

    Helped me a lot!
    I made some modifications to this expression, to make it the most common AE FX.
    As an example, add a “Slider Control” on the key frame.
    example:

    effect (“Slider Control”) (“Slider”) added in place of the value of “beginCount” and “endCount”

    beginCount = effect (“Slider Control”) (“Slider”);
    endCount = effect (“Slider Control”) (“Slider”);

    So you have control over the length “dur”
    What you can put as “0”

    For only with such modifications you already have the control when it starts and ends when through the key frame.

  • Danielle See

    May 15, 2013 at 2:32 pm

    Another thank you from me, I’m so stoked with this!!

  • Ernesto Sanchez

    March 24, 2014 at 7:06 pm

    I’m working on a project and I used this code and it works great, thank you for that!

    I’m trying to include text at the end of the number, for example, I have the the counter ending at $4.2 but I wanted to add the “M” after the number 2, how can I do that.

    Please help.

  • Dan Ebberts

    March 24, 2014 at 7:36 pm

    You should be able to change the last 4 lines to something like this:

    prefix + outStr + decimals + “M”;
    }else{
    prefix + s + “M”;
    }

    Dan

  • Ernesto Sanchez

    March 24, 2014 at 8:44 pm

    It worked! Thank you Dan!

Page 1 of 2

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