I'm trying to work out a counter that simply goes like:
2.5M views
At the moment I've got this expression working along with a Slider Control:
var num = effect("Slider Control")("Slider")
num = Comma(num) + "M views";
[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;
}
This though only makes my text layer go like:
2M views
I've tried already replacing the first line with:
effect("Slider Control")("Slider").value.toFixed(2)
But this adds a decimal followed by a comma normally, it doesn't work anyways on this expression but maybe it can help.
Thanks in advance.