 Technique for Animated Number Countdown with Commas
•    
 Technique for Animated Number Countdown with Commas
by Randy Rubin on Feb 9, 2012 at 12:04:14 am 
Hi All,
Ran into this issue and combined like two techniques to get a really easy solution  thought I'd share it.
To get a number to countdown (from say 256,000 to 152,000 with commas, no decimal) follow these steps. (I didn't write most of the expression, got it from a website)
1. Create an empty text layer.
2. Go to Effects > Expression Controls > Slider Control
3. Twirl Down the Text Layer and 'alt (option on mac) + click' Text Source to open expression editor.
4. Enter the expression below.
5. Use the slider control effect to animate number. Enter the actual value instead of using the slider for numbers larger than one hundred. Simply key frame the effect and use the character editor to format the text. (Goes as high as 1,000,000)
Expression:
var num = effect("Slider Control")("Slider")
num = Comma(num);
[num]
function Comma(number)
{
number = '' + Math.round(number);
if (number.length > 3)
{
var mod = number.length % 3;
var output = (mod > 0 ? (number.substring(0,mod)) : '');
for (i=0 ; i < Math.floor(number.length / 3); i++)
{
if ((mod == 0) && (i == 0))
output += number.substring(mod+ 3 * i, mod + 3 * i + 3);
else
output+= ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);
}
return (output);
}
else return number;
}
    
•      Re: Technique for Animated Number Countdown with Commas by John Cuevas on Feb 9, 2012 at 1:14:17 am 
Very nice, saved to useful expressions folder.
Johnny Cuevas, Editor
Thinkck.com
"I have not failed 700 times. I have succeeded in proving that those 700 ways will not work. When I have eliminated the ways that will not work, I will find the way that will work."
THOMAS EDISON on inventing the light bulb.
    
•      Re: Technique for Animated Number Countdown with Commas by Roland R. Kahlenberg on Feb 9, 2012 at 6:31:27 pm 
Thanks for sharing Randy.
Cheers
RoRK
Intensive AE & Mocha Training in Singapore and Malaysia
Adobe ACE/ACI (version 7) & Imagineer Systems Inc Approved Mocha Trainer
    
•      Re: Technique for Animated Number Countdown with Commas by Adam Lewen on Jun 10, 2012 at 7:49:27 pm 
Thanks! This share helped me a lot!
    
•      Re: Technique for Animated Number Countdown with Commas by Dan Smith on Jun 27, 2012 at 4:56:09 pm 
Is there a way to do 1,000,000+ ? I need a population counter....
    
•      Re: Technique for Animated Number Countdown with Commas by Conrad DSouza on Mar 20, 2013 at 4:59:12 pm 
my problem is the same as someone else posted; need to show a population countup from 0 or 100,000 to over 1 billion or over.
    
•      Re: Technique for Animated Number Countdown with Commas by Ryan Paterson on Jul 15, 2013 at 9:30:24 pm 
This is probably too late but I just saw this post now, to go over a million, just multiply the slider value in the first line of the expression like so
var num = effect("Slider Control")("Slider") * 100 (or whatever number you want)
    
• •      Re: Technique for Animated Number Countdown with Commas by Marcello Sanna on Apr 30, 2014 at 6:02:02 pm 
This is very useful, thanks for sharing!
In Italy we use commas instead of dots, so I would need to place the comma only before the last (or last two) digit.
I tried this way
var num = effect("Slider Control")("Slider")
num = Comma(num);
[num]
function Comma(number)
{
number = '' + Math.round(number);
if (number.length > 2)
{
var mod = number.length % 1;
var output = (mod > 0 ? (number.substring(0,mod)) : '');
for (i=0 ; i < Math.floor(number.length / 1); i++)
{
if ((mod == 0) & (i == 0))
output += number.substring(mod+ 1 * i, mod + 1 * i + 1);
else
output+= ',' + number.substring(mod + 1 * i, mod + 1 * i + 1);
}
return (output);
}
else return number;
}
but I get a comma after every digit.
Any idea?
Thank you!
    
 
