Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Count frames until an animation property reaches a certain value

  • Count frames until an animation property reaches a certain value

    Posted by Klaus Hertweck on May 16, 2025 at 9:50 am

    I have a simple animation, a shape layer is moving from left to right.

    Now I want know at which frame the X-value of the reaches 500.

    I have set up this expression, but it does not work:

    var compLength = thisComp.duration / thisComp.frameDuration;

    var posX = thisComp.layer(“shape”).transform.xPosition;

    for (i = 0; i <= compLength; i++) {
    posX.valueAtTime(framesToTime(i)) = 500
    }
    i

    i should return the frame value, but is doesn’t.

    Any help would be greatly appreciated.

    Brie Clayton
    replied 12 months ago
    4 Members · 6 Replies
  • 6 Replies
  • Dan Ebberts

    May 16, 2025 at 11:07 am

    You were close. Try it this way:

    var compLength = thisComp.duration / thisComp.frameDuration;
    var posX = thisComp.layer("shape").transform.xPosition;
    for (i = 0; i <= compLength; i++) {
    if (posX.valueAtTime(framesToTime(i)) >= 500) break;
    }
    i
  • John Martin

    May 16, 2025 at 11:07 am

    i’m recording a custom tutorial for you with the solution, just wait for a little bit and you’ll see it!

  • John Martin

    May 16, 2025 at 11:48 am
  • Klaus Hertweck

    May 16, 2025 at 12:55 pm

    Hi Dan,

    thanks a lot! This works perfectly!

  • Klaus Hertweck

    May 16, 2025 at 1:00 pm

    Hi John,

    thank you very much for visualising your solution!

  • Brie Clayton

    May 16, 2025 at 11:27 pm

    Thanks for solving this, John!

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