ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

How would I add Milliseconds to this expression?

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jackson RedshawHow would I add Milliseconds to this expression?
by on May 26, 2014 at 5:54:11 am

Hi Guys,

Just wondering how I would add milliseconds to this expression?

rate = -1;
clockStart = 388;

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

clockTime = Math.max(clockStart + rate*(time - inPoint),0);

t = Math.floor(clockTime);
min = Math.floor((t%3600)/60);
sec = Math.floor(t%60);

min + ":" + padZero(sec)


Thanks

Jackson
http://www.youtube.com/MITLRproductions


Return to posts index

Dave LaRondeRe: How would I add Milliseconds to this expression?
by on May 26, 2014 at 6:10:25 am

At what frame rate do you need to deliver your finished work? If it's one of the standard rates, whether you have the ability to add or delete a few milliseconds or not is irrelevant.

Dave LaRonde
Promotion Producer
KGAN (CBS) & KFXA (Fox) Cedar Rapids, IA


Return to posts index

Jackson RedshawRe: How would I add Milliseconds to this expression?
by on May 26, 2014 at 6:14:29 am

Hi Dave,

The frame rate is 25. At the moment, only the minute/s and second/s are displayed on the screen

Thanks

Jackson
http://www.youtube.com/MITLRproductions


Return to posts index


Jackson RedshawRe: How would I add Milliseconds to this expression?
by on May 26, 2014 at 1:14:31 pm

I think you misunderstood the question, entirely my fault though.

The expression is generating a countdown clock on the screen. But only the minute/s and seconds are displayed.

Thnaks

Jackson
http://www.youtube.com/MITLRproductions


Return to posts index

Walter SoykaRe: How would I add Milliseconds to this expression?
by on May 26, 2014 at 1:26:45 pm

rate = -1;
clockStart = 388;

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

clockTime = Math.max(clockStart + rate*(time - inPoint),0);

t = Math.floor(clockTime);
min = Math.floor((t%3600)/60);
sec = Math.floor(t%60);
milliseconds = clockTime.toFixed(3).split(".")[1];

min + ":" + padZero(sec) + "." + milliseconds;



The magic happens here:
milliseconds = clockTime.toFixed(3).split(".")[1];

Here's a translation. toFixed() is a method that converts a number to a string with a fixed number of decimal places (in this use above, 3). It will pad with zeroes as necessary to maintain this fixed number.

split() is a method which splits a string into an array of substrings when given a separator. In this case, the separator is a period. For the string "0.123.456", split(".") yields this array of strings: ["0","123","456"]. We use array indices to access a specific substring.

In plain English, the above line says convert the clock time to a string including 3 decimal places, then take only the digits after the decimal point and call them "milliseconds."

Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

Jackson RedshawRe: How would I add Milliseconds to this expression?
by on May 26, 2014 at 1:28:37 pm

Thanks so much Walter. Worked Perfectly!

Jackson
http://www.youtube.com/MITLRproductions


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]