Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Pulling min and max data from keyframes

  • Pulling min and max data from keyframes

    Posted by Brock Jolet on February 19, 2013 at 9:49 pm

    I’m trying to write an expression that would dynamically adjust according to the minimum and maximum values that are keyed.

    For example, if I keyed the opacity of a layer from 0 to 50 then back to 25, the minimum value would be 0 and the maximum value would be 50.
    If I then changed one of the keyframes to -25, that would dynamically become the new minimum value.

    My goal is to then use these two values (minimum and maximum) in a subsequent linear function that controls a separate process. I’m not sure where to start with this one and any help would be appreciated. I’m hoping it’s a very simple function that I cannot find.

    Brock Jolet replied 13 years, 2 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    February 19, 2013 at 10:34 pm

    Something like this should work:


    myProp = transform.opacity;
    if (myProp.numKeys > 0){
    myMin = 9999;
    myMax = -9999;
    for (i = 1; i <= myProp.numKeys; i++){
    myMin = Math.min(myMin,myProp.key(i).value);
    myMax = Math.max(myMax,myProp.key(i).value);
    }
    }else{
    myMin = myMax = myProp.value;
    }

    Dan

  • Brock Jolet

    February 19, 2013 at 10:38 pm

    Thank you very much. This successfully pulls the maximum value and since it’s opacity, the minimum will be zero. Just for curiosity’s sake, how would I extract the minimum from this expression should it differ?

  • Brock Jolet

    February 19, 2013 at 10:41 pm

    Nevermind, I figured it out. Brain fart. Thanks again.

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