Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Clock expression Mod

  • Clock expression Mod

    Posted by Harrison Willett on August 18, 2008 at 2:26 pm

    I am using the expression

    rate = 5023.4;
    clockStart = 0;

    function padZero(n){
    if (n < 10) return "0" + n else return "" + n } clockTime = clockStart + rate*(time); but I would like for the decimal to be a constant "x" number of units how do I go about achieving this? Also is it possible to do the same with the front end and add zeros as buffer in the whole digits? for example frame two could be 000167.614 instead of 167.61428094714

    Harrison Willett replied 17 years, 11 months ago 3 Members · 4 Replies
  • 4 Replies
  • Mike Clasby

    August 18, 2008 at 4:45 pm
  • Harrison Willett

    August 18, 2008 at 8:06 pm

    I agree that they are very versatile but, that is where I got the expression from in the first place. I am still trying to find help to make the units stay in the same place since i could not find the answer in these links.

    Again I want to find a way to make my units stay in the same place so that if I am using 5 units the number 25 would be written 00025

    Understanding how to add units on both ends of the decimal would be helpful.

    If the answer is in these links can someone hold my hand and walk me though this. I am still very confused.

    thanks again

  • Dan Ebberts

    August 18, 2008 at 8:28 pm

    Try this:

    numDigits = 6;
    numDecimals = 3;

    rate = 5023.4;
    clockStart = 0;

    function padZeros(theNumber,numDigits){
    s = theNumber;
    while (s.length < numDigits) s = "0" + s; return s } clockTime = clockStart + rate*(time); clockTime = clockTime.toFixed(numDecimals); splitTime = clockTime.split("."); if (numDecimals > 0){
    padZeros(splitTime[0],numDigits) + “.” + splitTime[1]
    }else{
    padZeros(splitTime[0],numDigits)
    }

    Dan

  • Harrison Willett

    August 19, 2008 at 3:02 am

    Dan once again you are amazing and so is your site thank you so much.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy