Activity › Forums › Adobe After Effects › Technique for Animated Number Countdown with Commas
-
Technique for Animated Number Countdown with Commas
Claire Presnall replied 2 years, 9 months ago 26 Members · 27 Replies
-
Nick Hamilton
November 26, 2015 at 12:07 pmAnd 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;
} -
Liran Tabib
April 22, 2016 at 7:12 amyou can use a different approach and create the animation with the counter preset: https://www.vdodna.com/products/counter-preset/
-
David Crowther
April 24, 2017 at 8:00 amNew 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”)[0]
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;
} -
Jameel Choudhury
June 20, 2017 at 2:12 pmHi 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
-
David Crowther
June 20, 2017 at 6:22 pmHi Jameel,
You can add it to the num variable like so:
var num = effect(“Point Control”)(“Point”)[0]
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;
} -
Erik Waluska
October 30, 2018 at 4:54 pm -
Tomáš Lyga
November 6, 2018 at 12:19 pmHi, 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 amIn CC2019 first go to: File • Project Settings • Expressions ; set it to Legacy ExtendScript
-
Milan Karmakar
June 21, 2019 at 7:29 amHi There,
the Expression not working in my after effects cc 2019 version.please help me out
Reply to this Discussion! Login or Sign Up