Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions start/stop expression at specific time

  • start/stop expression at specific time

  • atomicrabbit

    July 27, 2007 at 7:12 pm

    Is there a way to start/stop an expression at a specific time. I’ve tried using a checkbox with if statement to start it at a specific frame and it worked fine, but when I turn it off to stop the expression, it does not stay at the position the expression moved it to. It reverts to the size/position it was before the expression.

    How can I get around this problem.

  • Mike Clasby

    July 27, 2007 at 7:25 pm

    ok, somebody will have a more sophisticated solution, but to keep that expression value (Position) you can always split the layer (Edit>Split Layer) then on that upper layer set a Position keyframe (or whatever property the expression is on), then disable the expression (click the equal sign next to the stopwatch). You should be good to go.

  • Dan Ebberts

    July 27, 2007 at 8:04 pm

    What’s the code for your expression?

    Dan

  • atomicrabbit

    July 27, 2007 at 8:08 pm

    [Dan Ebberts] “What’s the code for your expression?

    Dan”

    I found this code from a post. It’s to make a falling leaf effect, but I modified the code a little. I’m also using a checkbox to start the expression.

    position
    ———————————————————————————–
    control = effect(“Checkbox Control”)(“Checkbox”) ;
    whattime=time-3;
    if (control == 1){
    sp=2;
    amp=150;
    gravity = 50;
    x = Math.sin(whattime*sp)*amp;
    y = Math.sin(whattime*1.5)*50;
    value + [x,y];
    }else{
    value;
    }

    scale
    ————
    control = effect(“Checkbox Control”)(“Checkbox”) ;
    whattime=time-3;
    if (control == 1 || value > 40){
    gravity = 50;
    z= whattime*whattime
    value – [z,z];
    }else{
    value;
    }

    rotation
    ————————————————————————————
    control = effect(“Checkbox Control”)(“Checkbox”) ;
    whattime=time-3;
    if (control == 1){
    sp=2;
    amp=5;
    x = Math.sin(whattime*sp)*amp;
    value – x;
    }else{
    value;
    }

  • Dan Ebberts

    July 27, 2007 at 8:38 pm

    Give this a try (for position):

    chkBx = effect(“Checkbox Control”)(“Checkbox”);

    n = 0;
    if (chkBx.numKeys > 0){
    n = chkBx.nearestKey(time).index;
    if (chkBx.key(n).time > time){
    n–;
    }
    }

    t = 0;
    curTime = time;

    if (n > 0){
    for (i = n; i > 0; i–){
    if (chkBx.key(i).value > 0){
    t += (curTime – chkBx.key(i).time);
    }
    curTime = chkBx.key(i).time;
    }
    if ((curTime > 0) && (chkBx.key(1).value > 0)) t += curTime;
    }else{
    if (chkBx.value > 0) t = time;
    }

    sp=2;
    amp=150;
    gravity = 50;
    x = Math.sin(t*sp)*amp;
    y = Math.sin(t*1.5)*50;
    value + [x,y];

    Dan

  • George Costakis

    April 4, 2009 at 11:43 pm

    I doubt anyone will see this, but what about for this expression?

    veloc = 7;
    amplitude = 80;
    decay = .7;

    amplitude*Math.sin(veloc*time)/Math.exp(decay*time)

    right now it starts at the beginning of the comp even if i try the split and duplicate layer trick. any help would be great.
    -george

  • Brennan Shappell

    August 25, 2010 at 4:25 pm

    I also am trying to get the decaying pendulum expression to start at a time specified(not the beginning of the comp).
    Thanks for any help!

    veloc = 5;
    amplitude = 20;
    decay = .9;

    amplitude*Math.sin(veloc*time)/Math.exp(decay*time)

  • Dan Ebberts

    August 25, 2010 at 5:31 pm

    This is one way:


    beginTime = 4; // start at 4 seconds
    if (time < beginTime){
    0
    }else{
    t = time - beginTime;
    veloc = 5;
    amplitude = 20;
    decay = .9;
    amplitude*Math.sin(veloc*t)/Math.exp(decay*t)
    }

    Dan

  • Brennan Shappell

    August 25, 2010 at 5:36 pm

    Thanks for the absurdly fast turn around time on that, Dan =]
    Works like a charm.

  • Duca Simone Luchini

    October 27, 2011 at 7:56 pm

    Hallo Dan, I didn’t understand in this your code where is the END parameter where the expression stops. I Understood that at 4 second starts expression (beginTime = 4;)
    BUT where stops???
    For instance, in your expression (), if the comp is 10 seconds and I’d like to activate expression from 2 second to 8 second, what I have to write?

    beginTime = 4; // start at 4 seconds
    if (time < beginTime){ 0 }
    else{ t = time – beginTime;
    veloc = 5; amplitude = 20; decay = .9; amplitude*Math.sin(veloc*t)/Math.exp(decay*t) }

    THX!

Viewing 1 - 10 of 44 posts

Log in to reply.

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