Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Keyframes with Expression

  • Keyframes with Expression

    Posted by Duane Walters on September 10, 2020 at 12:07 pm

    Hello there!
    I create lower thirds all the time, and I use if/then statements to hide the subline box if there is no text for the box.
    Something like this:

    if (thisComp.layer("subline").text.sourceText.length >0) {

    100

    } else {

    0

    }

    But in this particular case, I have keyframes to animate the subline box in, and using that expression my keyframes are not being utilized.

    How would I go about doing this?

    Thanks in advance.

    Brendon Murphy replied 5 years, 8 months ago 3 Members · 9 Replies
  • 9 Replies
  • Dan Ebberts

    September 10, 2020 at 12:20 pm

    Try it this way:

    if (thisComp.layer("subline").text.sourceText.length > 0) {

    value;

    } else {

    0;

    }

  • Duane Walters

    September 10, 2020 at 12:36 pm

    What if I wanted to scale the headline text down if there is a subline text present?

    I’m getting that pesky “must be of dimension 2, not 1” error.

  • Dan Ebberts

    September 10, 2020 at 1:09 pm

    Like this maybe:

    if (thisComp.layer("subline").text.sourceText.length > 0) {

    value;

    } else {

    [0,0];

    }

  • Duane Walters

    September 10, 2020 at 1:12 pm

    So, can you explain to me what the “value” is doing?

  • Duane Walters

    September 10, 2020 at 1:34 pm

    Furthermore, is there a way I can sort of trigger the scaling to happen when the subline animation happens?

    It would be cool to make it triggered, but just being able to delay the scale animation by frames or seconds would be cool too.

    Thanks for all of your massive contributions to expressions Dan, you truly are amazing.

  • Dan Ebberts

    September 10, 2020 at 1:57 pm

    value just says to use the keyframed/static value of the property. So in this case, it’s telling the expression not to do anything.

  • Brendon Murphy

    September 10, 2020 at 3:36 pm

    What kind of animation is on the subline?

  • Brendon Murphy

    September 10, 2020 at 5:55 pm

    I’ll assume that you are trying to drive the headline size by animating the subline’s Source Text. AE sees the length of an empty text layer as 1, so if you want the headline scale to be 0 when the source text is empty, you’ll need to do:

    if (thisComp.layer("subline").text.sourceText.length > 1) {

    value;

    } else {

    [0,0];

    }

  • Brendon Murphy

    September 10, 2020 at 9:00 pm

    Just for the heck of it –

    if you would like to have the headline scale-in over a duration instead of just popping on, add a slider called “Scale duration” to the headline layer and use the below expression. Note that this assumes there are only two key frames on the subline, animating it from empty text to not empty. This also assumes that the headline has a uniform scale.

    subText = thisComp.layer(“subline”).text.sourceText;

    subTextLength = subText.value.length;

    if(subTextLength>1){

    heroKey = thisComp.layer(“subline”).text.sourceText.nearestKey(time);

    scaleStart = heroKey.time;

    scaleEnd = heroKey.time+(effect(“Scale duration”)(“Slider”)/(1/thisComp.frameDuration));

    scalePerFrame = value[0]/(scaleEnd-scaleStart);

    if(time<=scaleStart){

    [0,0];

    };

    if(time>scaleStart&&time<scaleEnd){

    [(time-scaleStart)*scalePerFrame,(time-scaleStart)*scalePerFrame];

    };

    if(time>=scaleEnd ){

    [value[0],value[1]];

    };

    }else{[0,0]};

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