Digital Clock time

rook

Veteran
Hey guys,

I need a way of animating a digital clock.

Take a look at this clip I did to get an idea of what I mean: (15 seconds in)

http://vimeo.com/3302520

For the clip above I used this script (below) that I found art motionscript.com:


rate = -2;
clockStart = 3604.999;

function padZero(n){
if (n < 10) return "0" + n else return "" + n
}

clockTime = clockStart + rate*(time - inPoint);

if (clockTime < 0){
sign = "-";
clockTime = -clockTime;
}else{
sign = "";
}

t = Math.floor(clockTime);
hr = Math.floor(t/3600);
min = Math.floor((t%3600)/60);
sec = Math.floor(t%60);
ms = clockTime.toFixed(3).substr(-3);
sign + padZero(hr) + ":" + padZero(min) + ":" + padZero(sec) + "." + ms


My problem is that I had to mask out the first set of numbers and set the clock with a value like "3604.999".

The issue is that for the next graphic I need to have a lot of layers (100+) all ticking away at different times. Adding the script to each, masking out the first two digits and setting the time seems to be a poor work choice.

Is there a way of modifying this script to lose the first digits? A better script?

A preset to apply the script to all layers and randomize the time value would be awesome but I don't even know where to begin to do that.

I hope I am clear here but if I make no sense let me know and I'll clarify.

Any ideas are appreciated.

Thanks peeps.
 
Hey Rook,

I made a few changes to your script, getting rid of the milliseconds after the period and letting you put the clockStart value to 0 instead of 3604.99.

This way you won't have to mask out unwanted numbers for all the layers.

You may notice that I made the clockStart value refer to a Slider Control that you need to add to the text layer (Effect> Expression Controls> Slider Control). This might make it easier to adjust the time for each layer. Its still a pain cause you will have to go through each layer to change it but I guess its a start haha.

I also added AM and PM, AM if slider value is <0 and PM if value is >0

One more thing, I multiplied the Slider Control by 60 so 1 unit on the slider equals 1 minute. Similarly you can mupltiply it by 1 to change by seconds or multiply it by 3600 to change by hour.

Let me know if this helps or if I did completely the wrong thing haha.

--FS



Heres the script:

rate=2
clockStart = (effect("Slider Control")("Slider")) *60;

function padZero(n){
if (n < 10) return "0" + n else return "" + n
}

clockTime = clockStart + rate*(time - inPoint);

if (clockTime < 0){
sign = " AM";
clockTime = -clockTime;
}else{
sign = " PM";
}

t = Math.floor(clockTime);
hr = Math.floor(t/3600);
min = Math.floor((t%3600)/60);
sec = Math.floor(t%60);
padZero(hr) + ":" + padZero(min) + ":" + padZero(sec) + sign
 
Last edited:
This is awesome.

If the expression works as planned you just saved me from a stack of headaches.

I'm on another project for a few days but I'm back on the Bumper graphic mid week.

I cannot wait to try this out.

I'll let you know how it goes and THANK YOU!

I appreciate the help.

-rook
 
No problem

Once again, let me know if somethings not how you like it, I'll do the best I can to adjust it
 
Dude, that is way easier to work with. Thank you so much. the slider control makes it so much easier to work this.

It's still going to be be a mother of a build but you just made it a lot easier.

Thank you so much!!!
 
Back
Top