Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects A script to move a layer 10 pixels every 10 frames?

  • A script to move a layer 10 pixels every 10 frames?

    Posted by Jon Melot on October 28, 2015 at 2:24 pm

    Hi all,

    I’ve got a wide screen image (5446 pixels) in a 720 comp. I’m wondering if there’s is a way to use a script to move the image 10 pixels to the left every 10 frames. I had been doing this by hand and then replacing the keyframes with “hold keyframes”, but I figure there must be a better way. I don’t want fluid movement, just something really jerky.If I could make it loop, that would be awesome, but first things first!

    Any ideas?

    John Cuevas replied 10 years, 6 months ago 3 Members · 2 Replies
  • 2 Replies
  • Cassius Marques

    October 29, 2015 at 12:51 pm

    why a script? can’t you just add an expression?

    create two keyframes 10f and 10px apart, hold them(by ctrl+alt clinking) then alt click the stopwatch (to add an expression) and write:

    loopOut("offset")

  • John Cuevas

    October 29, 2015 at 3:35 pm

    And after seeing the perfect response from Cassius, here’s a much more complicated way of doing it. Expression to the position property:

    x = transform.position[0];
    y = transform.position[1];
    myTime = timeToFrames(t = time + thisComp.displayStartTime, fps = 1.0 / thisComp.frameDuration, isDuration = false);
    myCondition = myTime % 10;
    timeDown = myTime - myCondition

    if (myCondition == 0) ([x,y]) - [myTime,0] else [x-timeDown,y]

    Johnny Cuevas, Editor
    ThinkCK

    “I have not failed 700 times. I have succeeded in proving that those 700 ways will not work. When I have eliminated the ways that will not work, I will find the way that will work.”
    —THOMAS EDISON on inventing the light bulb.

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