Activity › Forums › Adobe After Effects Expressions › number counter
-
number counter
Posted by Reuben Fink on October 16, 2007 at 10:18 pmI’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 amHere’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
-
Troy Ruff
March 27, 2010 at 6:48 pmThank 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
-
Leandro Sarmento da silva
June 29, 2012 at 8:22 pmHelped 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.
-
Ernesto Sanchez
March 24, 2014 at 7:06 pmI’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 pmYou should be able to change the last 4 lines to something like this:
prefix + outStr + decimals + “M”;
}else{
prefix + s + “M”;
}Dan
Reply to this Discussion! Login or Sign Up