Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Value in relation to keyframes

  • Aaron Pozzer

    September 8, 2011 at 12:25 pm

    hey Dan. just wondering if its possible to add a time offset in there? as it stands now, the fades in/out start/end at the keyframes, and thats exactly correct, but not what i was expecting for some reason. its fine how it is… i just added extra frames at the head and tail of the animation to get the layers faded in when i wanted them, in relation to the animation. for some reason i thought the fade in/out would start before the 1st key and be 100% by the time it hit that 1st key, and then start fading out on the last key and be 0% however many frames after the last key.

    again, its fine this way, as i can tweak it with additional keys, but right now the only thing i can change is how fast the fade in happens. it would be great if i could offset the effect by some frames so that each layer/property using the script doesnt start/end at the same time.

    thanks!

  • Dan Ebberts

    September 8, 2011 at 1:15 pm

    Try changing the in and out eases line this:

    ease(time,t0-t,t0,0,100)

    ease(time,t1,t1+t,100,0)

    Dan

  • Aaron Pozzer

    September 8, 2011 at 3:42 pm

    that did it! good stuff. i tried to add in an offset function as follows…

    p = property;
    fadeFrames = 10;
    offset = .1;

    if (p.numKeys > 1){
    t0 = p.key(1).time;
    t1 = p.key(p.numKeys).time;
    t = framesToTime(fadeFrames);
    if (time < (t0+t1)/2){
    ease(time,t0-t+offset,t0,0,100)
    }else{
    ease(time,t1+offset,t1+t,100,0)
    }
    }else{
    value
    }

    this works, but it seems what it does is offset the value changes start, but not its finish. so the fade still happens in 10 frames, it just waits to start the fade, and then the fade has to be accomplished in fewer frames. also, i think cause of your framesToTime i had to put the offset as .1, because i think its in time, not frames.

  • Zoltán Riskó

    March 20, 2018 at 11:29 pm

    Hey Dan, very very old thread but thanks for it!
    The first expression works for me like a charm but when I reach the last keyframe it’s set to default. If I duplicate the last keyframe I can avoid it but it would be more elegant when I reach the last keyframe and I leave it in the timeline the value is still the last keyframe’s value. Could you help how can I achieve this? Thanks!

    p = transform.position; // property you want to monitor
    v = value;
    if (p.numKeys > 0){
    n = p.nearestKey(time).index;
    if (p.key(n).time > time) n--;
    if (n > 0 && n &lt; p.numKeys)
    v = linear(time,p.key(n).time,p.key(n+1).time,0,100);
    }
    v

  • Dan Ebberts

    March 21, 2018 at 12:06 am

    Like this maybe:


    p = transform.position; // property you want to monitor
    v = value;
    if (p.numKeys > 0){
    n = p.nearestKey(time).index;
    if (p.key(n).time > time) n--;
    if (n > 0 && n < p.numKeys)
    v = linear(time,p.key(n).time,p.key(n+1).time,0,100)
    else if (n == p.numKeys)
    v = 100;
    }
    v

    Dan

  • Zoltán Riskó

    March 21, 2018 at 6:37 am

    Oh yes that’s it! Thank you very much! You are awesome! 🙂

Page 2 of 2

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