Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions How to change “beginTime = thisLayer.inPoint” to keyframe or checkbox?

  • How to change “beginTime = thisLayer.inPoint” to keyframe or checkbox?

    Posted by Stephen Pickering on March 13, 2013 at 10:54 pm

    Hi there,
    I have a comp which uses the following expression:

    beginTime = thisLayer.inPoint;
    if (time < beginTime){
    0
    }else{
    t = time - beginTime;
    veloc = [effect("Velocity")("Slider")]*.1;
    amplitude = effect("Amplitude")("Slider");
    decay = [effect("Decay")("Slider")]*.01;
    amplitude*Math.sin(veloc*t)/Math.exp(decay*t) }

    It’s a pendulum expression from Cineblur. I would like however to not have the sway start at the layer’s in point but rather at a keyframe or a “checkbox” I was able to get it to react to a checkbox control(by replacing “thisLayer.inPoint.” But because it has a decay expression it begins decaying right away from “inPoint” even though there is no movements until the checkbox was ticked. So basically if I ticked the box at 5 seconds but it has a 7 second decay it only shows subtle movement for 2 seconds, beginning at 5 seconds. Does that make sense?

    Any ideas?

    Thank you!

    -Stephen

    Stephen Pickering replied 13 years, 5 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    March 13, 2013 at 11:16 pm

    What did you change the first line to? I would think you’d want something like this:

    beginTime = effect(“Checkbox Control”)(“Checkbox”).key(1).time;

    Dan

  • Stephen Pickering

    March 14, 2013 at 3:54 am

    I believe I had changed it to something like:

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

    But it looks like your expression works. Thank you very much. Can you tell me what the “.key(1).time” does?

    Is there any way to make a checkbox that turns it on again? I’m working on a venetian blinds effect. The expression above is for the “sway” which is the result of the blinds closing. The blinds will open and close multiple times so i would need to repeat this decaying pendulum sway multiple times.

    Thanks Dan!

    -Stephen

  • Dan Ebberts

    March 14, 2013 at 4:14 am

    key(1).time gives you the time of the first checkbox keyframe.

    If you want to trigger it at every checkbox keyframe, you could do it like this:


    cb = effect("Checkbox Control")("Checkbox");

    n = 0;
    if (cb.numKeys > 0){
    n = cb.nearestKey(time).index;
    if (cb.key(n).time > time) n--;
    }
    if (n == 0){
    0;
    }else{
    t = time - cb.key(n).time;
    veloc = effect("Velocity")("Slider")*.1;
    amplitude = effect("Amplitude")("Slider");
    decay = effect("Decay")("Slider")*.01;
    amplitude*Math.sin(veloc*t)/Math.exp(decay*t)
    }

    Dan

  • Stephen Pickering

    March 14, 2013 at 4:32 am

    Works perfectly Dan, Thanks!

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