Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Keyframes as a Var

  • Keyframes as a Var

  • Gigi Ophir

    May 20, 2022 at 11:48 pm

    Hi,

    Is it possible to define a set of keyframes as a var ?

    For example, layer’s opacity going from 0-100 in ten frames.

    I would like to be able to call this behavior?

    Thanx

  • Dan Ebberts

    May 21, 2022 at 3:37 pm

    I’m not sure how you would do that, or how you would trigger it if you could do it.

    I have no idea if this is of any use to you, but you could define a set of “action” functions that would respond to specific triggers. For example, you could set up some opacity functions that could be triggered by layer markers. In this simple example, layer markers with the comment “fadeIn”, “fadeOut”, “flickerOn”, or “flickerOff” would trigger a specific function. Each comment can also include an option duration (in frames) parameter, so, for example, you could trigger a 25-frame fadeIn with this comment: “fadeIn 25”. If no duration parameter is included, a default of 10 frames is assumed. This opacity expression is a simplified version of such a marker-triggered system:

    function fadeIn(t,dur){

    return linear(t,0,dur,0,100);

    }

    function fadeOut(t,dur){

    return linear(t,0,dur,100,0);

    }

    function flickerOn(t,dur){

    return t < dur ? (random() < 0.5 ? 0 : 100) : 100;

    }

    function flickerOff(t,dur){

    return t < dur ? (random() < 0.5 ? 0 : 100) : 0;

    }

    defaultDur = 10; // default duration in frames

    val = value;

    m = marker;

    if (m.numKeys > 0){

    n = m.nearestKey(time).index;

    if (time < m.key(n).time) n--;

    if (n > 0){

    c = m.key(n).comment.split(" ");

    myDur = framesToTime(c.length > 1 ? parseInt(c[1]) : defaultDur);

    myT = time - m.key(n).time;

    switch(c[0]){

    case "fadeIn":

    val = fadeIn(myT,myDur);

    break;

    case "fadeOut":

    val = fadeOut(myT,myDur);

    break;

    case "flickerOn":

    val = flickerOn(myT,myDur);

    break;

    case "flickerOff":

    val = flickerOff(myT,myDur);

    break;

    default:

    break;

    }

    }

    }

    val

  • Filip Vandueren

    May 22, 2022 at 3:00 pm

    Motion developper has this library:

    https://motiondeveloper.com/tools/ekeys

    which allows you to do “keyframe”-like including easing animation via expressions instead of doing multiple linears/eases…

Viewing 1 - 3 of 3 posts

Log in to reply.

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