# Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Technique for Animated Number Countdown with Commas

• # Technique for Animated Number Countdown with Commas

• var num = effect(“Slider Control”)(“Slider”)*10
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;
}

• And if you would like to count over 1,000,000 and keep the comma’s in:

startCount = 0;
endCount = 48000000;
countDur = 3;

var num = Math.round(linear(time,0,countDur,startCount,endCount))
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;
}

• you can use a different approach and create the animation with the counter preset: https://www.vdodna.com/products/counter-preset/

• New response to old post, this helped me a lot with a project I am working on. However, I used point control instead of slider to overcome the arbitrary 1,000,000 limit.

The expression was (including commas):

var num = effect(“Point Control”)(“Point”)

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

• Hi David,

This expression is extremely helpful for what I need in my project. I just had 1 question, how do I go about including a £ or \$ symbol at the beginning of the number as it counts up?

Thanks

• Hi Jameel,

You can add it to the num variable like so:

var num = effect(“Point Control”)(“Point”)

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

• Can you do this and have 2 decimal places after it too?

• Exactly what I needed. Worked perfect. Thank you!!

Erik Waluska
EAWmedia

• Hi, for some reason this code (or any other similar to this one) doesn’t work with Adobe After Effects CC 2019. Do you have any idea why is that? Thank you

• ### Magdalena Kašparová

March 8, 2019 at 11:46 am

In CC2019 first go to: File • Project Settings • Expressions ; set it to Legacy ExtendScript

Viewing 11 - 20 of 27 posts

Log in to reply.

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