FORUMS: list search recent posts

# Pulling min and max data from keyframes

FAQ   •   VIEW ALL
 Pulling min and max data from keyframes on Feb 19, 2013 at 9:49:54 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.

 Re: Pulling min and max data from keyframeson Feb 19, 2013 at 10:34:31 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

 Re: Pulling min and max data from keyframeson Feb 19, 2013 at 10:38:40 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?

 Re: Pulling min and max data from keyframeson Feb 19, 2013 at 10:41:30 pm

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