Page 1 of 1

Count up

Posted: March 24th, 2010, 3:49 pm
by mikenyco
I created a script with a text object and a null object that does a simple count for a duration that I define with the null object.

Math.floor(thisComp.layer("Null 1").effect("Slider Control")("Slider"));

If I make the slider go to, let's say 10000 for example, is there a way to have the counter produce 0's before the number? Also, what about comma's?

Illustration:

Current-
0, 1, 2....125...250..999...1000...5000...9999....10000
(these are just random numbers but it technically produces every number 0 to 10000)

What I'd like to achieve to achieve is the following:
00000, 00001, 00002....00125....00250....00999....01,000....05,000....09,999...10,000

Re: Count up

Posted: March 24th, 2010, 4:18 pm
by Dan Ebberts
Try this:

Code: Select all

n = Math.floor(thisComp.layer("Null 1").effect("Slider Control")("Slider"));
s = "" + n;
len = s.length;
if (len > 3) s = s.substr(0,len-3) + "," + s.substr(-3);
for (i = 1; i <= 5 - len; i++) s = "0" + s;
Dan

Re: Count up

Posted: March 25th, 2010, 10:14 am
by mikenyco
Worked like a charm!

Thanks Dan!