ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Re: Technique for Animated Number Countdown with Commas

COW Forums : Adobe After Effects

FAQ   •   VIEW ALL   •   ADD A NEW POST   •   PRINT
Respond to this post   •   Return to posts index   •   Read entire thread


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


Posts IndexRead Thread 


Current Message Thread:





© 2017 CreativeCOW.net All Rights Reserved
[TOP]