Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions quick script help

  • Posted by Jalal Jemison on August 28, 2005 at 10:39 pm

    I need a timecode counter that displays “hours:mins:seconds” The Plugin “TIMECODE” in AE doesn’t allow a lot of modification of the text and the text bounces around a bit.

    It should be really easy to script for any of the pro’s out there. Here is what I have tried.

    var clockID = 0;

    function UpdateClock() {
    if(clockID) {
    clearTimeout(clockID);
    clockID = 0;
    }

    var tDate = new Date();

    document.theClock.theTime.value = “”
    + tDate.getHours() + “:”
    + tDate.getMinutes() + “:”
    + tDate.getSeconds();

    clockID = setTimeout(“UpdateClock()”, 1000);
    }
    function StartClock() {
    clockID = setTimeout(“UpdateClock()”, 500);
    }

    function KillClock() {
    if(clockID) {
    clearTimeout(clockID);
    clockID = 0;
    }
    }

    I have found some more like that but I get the “UNDEFINED” message in the window. I know I can do something with. Also I need it to go along with the comp timeline.
    something like..

    Math.round(linear(time,0,thisComp.duration-thisComp.frameDuration,0,20));

    Jalal Jemison replied 19 years, 5 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    August 29, 2005 at 12:37 am

    I’m not sure what you’re after exactly, but here’s a clock expression (for a text layer’s source text) that might help:

    
    beginTime = 0; // beginning time (seconds)
    mult = 1; // clock speed multiplier
    
    function digits(myVal,myNumDigits){
      var s = myVal.toString();
      while (s.length < myNumDigits) s = '0' + s;
      return s;
    }
    
    currTime = beginTime + time*mult;
    
    hr = digits(Math.floor(currTime/3600),2);
    min = digits(Math.floor((currTime%3600)/60),2);
    sec = digits(Math.floor(currTime)%60,2);
    ms = digits(Math.floor(currTime%1*1000),3);
    hr + ":" + min + ":" + sec + "." + ms
    
    

    If you want it to start at a time other than 0, set beginTime.
    If you want it to count faster or slower than comp time, modify mult.
    (mult = -1 will count down).

    Dan

  • Jalal Jemison

    August 29, 2005 at 1:22 am

    works great Dan. Thanks a lot.

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