Count up

Moderators: Disciple, zlovatt

Post Reply
mikenyco
Posts: 2
Joined: March 23rd, 2010, 2:48 pm

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
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

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
mikenyco
Posts: 2
Joined: March 23rd, 2010, 2:48 pm

Worked like a charm!

Thanks Dan!
Post Reply