Skip to main content
Participant
July 23, 2018
Answered

After Effects Number Generator

  • July 23, 2018
  • 2 replies
  • 4825 views

I need a number counter with comas that goes up to at least 100,000,000. Preferably infinitely. The "numbers" effect in AE only goes up to 30,000 (without a coma). This 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;

}

(located here: CreativeCOW ) is limited by the slider which only goes up to 1,000,000, but it does enable comas. Does anyone have a suggestion on how to make this work?

Thanks!

This topic has been closed for replies.
Correct answer Roland Kahlenberg

The Expression Point Control effect allows for larger numbers than the Expression Slider Control.

This script will do the trick for you - it includes a $ sign as a prefix.

s = "" + Math.round(effect("Point Control")("Point")[0]);

if (s.length > 3 && s.length < 7)

"$" + s.substr(0, s.length -3) + "," + s.substr(-3)

else if (s.length >= 7 && s.length < 10)

"$" + s.substr(0, s.length -6) + "," + s.substr(-6, 3)  +"," + s.substr(-3)

else if (s.length >= 10 && s.length < 13)

"$" + s.substr(0, s.length -9) + "," + s.substr(-9, 3) + "," + s.substr(-6, 3)  +"," + s.substr(-3)

else

"$" + s

-----------------------

I got the know-how over here -

Animated number count with commas in After Effects - YouTube

2 replies

Roland Kahlenberg
Roland KahlenbergCorrect answer
Legend
July 24, 2018

The Expression Point Control effect allows for larger numbers than the Expression Slider Control.

This script will do the trick for you - it includes a $ sign as a prefix.

s = "" + Math.round(effect("Point Control")("Point")[0]);

if (s.length > 3 && s.length < 7)

"$" + s.substr(0, s.length -3) + "," + s.substr(-3)

else if (s.length >= 7 && s.length < 10)

"$" + s.substr(0, s.length -6) + "," + s.substr(-6, 3)  +"," + s.substr(-3)

else if (s.length >= 10 && s.length < 13)

"$" + s.substr(0, s.length -9) + "," + s.substr(-9, 3) + "," + s.substr(-6, 3)  +"," + s.substr(-3)

else

"$" + s

-----------------------

I got the know-how over here -

Animated number count with commas in After Effects - YouTube

Very Advanced After Effects Training | Adaptive &amp; Responsive Toolkits | Intelligent Design Assets (IDAs) | MoGraph Design System DEV
Participant
July 24, 2018

Thanks! The video link helped a lot!

Legend
July 23, 2018

"Infinity" is not a valid concept for software.

Your code starts off by rounding the slider, which throws away the decimals. Multiply first to get your extra digits.

Community Expert
July 24, 2018

Goole Dan Eberts universal timer. That's where you should start.