Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Time change between two points

  • Time change between two points

    Posted by Chris Craig on December 19, 2014 at 4:01 am

    Hello everyone

    I am making an animation that has a 2 points, A & B at opposite ends of the frame (horizontal). Inbetween the 2 points, is an text layer with numbers (minutes and seconds). When i move the text layer closer to point A, I would like the numbers to decrease in time and when the text layer moves closer to point B, I would like the numbers to increase in time to the point where B = 1hr 15min 00secs.

    I appreciate anyones input.

    All the best and have a merry christmas.

    Chris

    Kevin Camp replied 11 years, 4 months ago 2 Members · 3 Replies
  • 3 Replies
  • Kevin Camp

    December 19, 2014 at 6:28 pm

    see if this works for you:
    xA = 100; // x value for point A
    tA = 0; // time value for point A in hours

    xB = 1000; // x value for point B
    tB = 1.25; // time value for point B in hours

    v = linear(position[0],xA,xB,tA,tB)*60*60/thisComp.frameDuration;

    t = timeToTimecode(framesToTime(v)).split(':');
    hr = t[0].split('').[1];
    min = t[1];
    sec = t[2];

    hr+'hr'+' '+min+'min'+' '+sec+'secs'
    set the xA and xB values as needed for the x values of points A and B. You didn’t mention a time values for point A, i assumed zero, but you can change if needed.

    since the expression uses the timeToTimcode() function, it is limited to 3 hours max, but this method makes it a little easier to get leading zeros for minutes and seconds, which I think you want. if the 3hr limit doesn’t work, there are other ways to get that formatting that aren’t limited to 3hrs.

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

  • Chris Craig

    December 20, 2014 at 1:41 am

    Thanks a lot Kevin

    I applied your code, but it returns a syntax error in line 10.

    Am i doing something wrong. I have AE cc

    Yes, the time does start at zero.

    Thanks a lot.

  • Kevin Camp

    December 22, 2014 at 5:39 pm

    Sorry Chris, there was an inadvertent period in the tenth line, change it to this:

    hr = t[0].split(”)[1];

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

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