Forum Replies Created

  • Jorge Diallo

    April 25, 2023 at 2:31 pm in reply to: get time at a value

    I had a similar problem: I’ve got text layer A with an opacity animator and a range selector. The start of the range selector has an expression, e.g. is a dynamic expression (depending on the length of the text). I’ve also got a text layer B with the same setup. The animation of the second animator is supposed to start 10 frames after the end of the animation of the first animator, e.g. the time at which the value reaches 100% for the first time.

    To do so, I needed an expression for the second animator to find that frame.

    Here’s the expression:

    var compLength = thisComp.duration / thisComp.frameDuration;
    var property = thisComp.layer("A").text.animator("X").selector("Y").start;
    var flag = false;
    var wantedFrame;
    
    for (var i = 0; i <= compLength; i++) {
        if (property.valueAtTime(i * thisComp.frameDuration) == 100)
        {flag = true; wantedFrame = i}
    
        if (flag == true) {break}
    }
    
    wantedFrame;

    The expression loops through every frame of the composition, starting at frame 0 and counting up to the very last frame (compLength). At every frame it looks at the value of the given property with .valueAtTime() and checks with an if-statement whether that value is equal to 100. If so, the flag variable is set true and the wantedFrame variable to that frame. At every iteration the for-loop looks with another if-statement whether the flag is true and if so, breaks out of the for-loop. The found frame (wantedFrame) is then returned.

    Replace property with whatever property you’re looking at and 100 with the value you’re looking for.

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