Creative COW SIGN IN :: SPONSORS :: ADVERTISING :: ABOUT US :: CONTACT US :: FAQ
Creative COW's LinkedIn GroupCreative COW's Facebook PageCreative COW on TwitterCreative COW's Google+ PageCreative COW on YouTube
ADOBE AFTER EFFECTS:HomeForumBasicsExpressionsTutorialsPodcastsAE TechniquesCreative Cloud DebateFAQ

Technique for Animated Number Countdown with Commas

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook
Randy RubinTechnique for Animated Number Countdown with Commas
by 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;
}


Return to posts index
Reply   Like  
+2

John CuevasRe: Technique for Animated Number Countdown with Commas
by 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.


Return to posts index
Reply   Like  

Roland R. KahlenbergRe: Technique for Animated Number Countdown with Commas
by 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


Return to posts index
Reply   Like  


Adam LewenRe: Technique for Animated Number Countdown with Commas
by on Jun 10, 2012 at 7:49:27 pm

Thanks! This share helped me a lot!


Return to posts index
Reply   Like  

Dan SmithRe: Technique for Animated Number Countdown with Commas
by on Jun 27, 2012 at 4:56:09 pm

Is there a way to do 1,000,000+ ? I need a population counter....


Return to posts index
Reply   Like  

Conrad DSouzaRe: Technique for Animated Number Countdown with Commas
by 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.


Return to posts index
Reply   Like  


Ryan PatersonRe: Technique for Animated Number Countdown with Commas
by 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)


Return to posts index
Reply   Like  

Marcello SannaRe: Technique for Animated Number Countdown with Commas
by 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!


Return to posts index
Reply   Like  

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook


FORUMSTUTORIALSFEATURESVIDEOSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

Creative COW LinkedIn Group Creative COW Facebook Page Creative COW on Twitter
© 2014 CreativeCOW.net All rights are reserved. - Privacy Policy

[Top]