Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions If (true) set value for next 4 frames

  • If (true) set value for next 4 frames

    Posted by Jeremy Wick on November 10, 2021 at 11:50 pm

    Is it possible to make an expression that, when triggered, changes the value for a set amount of frames? For example:

    if (statement == true) {

    // set opacity to 100 for next 4 frames, then 0

    } else {

    0

    }

    Andrei Popa replied 4 years, 6 months ago 2 Members · 1 Reply
  • 1 Reply
  • Andrei Popa

    November 12, 2021 at 6:45 am

    Hi Jeremy. Expressions can’t modify values in other places than the property on which they are applied, for the current frame. But for your case there is a workaround. You can evaluate the statement for the previous 3 frames, and if it’s true, make opacity 100. I imagine your statement checks the value of a property in the project, so you can use .valueAtTime() .

    Something like:

    durationCheck = 4;
    st = false;
    for(i = 0; i<durationCheck; i++){
    if( statement.valueAtTime(time-framesToTime(durationCheck)) == true ) st = true;
    }
    st == true ? 100 : 0;

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