Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Select looped clip depending on size of comp

  • Select looped clip depending on size of comp

    Posted by Roger Maus on April 27, 2012 at 10:44 pm

    So I got these four hand drawn animations of flowerpots. They are all the same, just different in size:


    (The 4 animations are separate, I just merged them for nicer gif, hehe.)

    The flowerpot will scale frenziedly.
    I’d like to find an expression which “selects” a loop according to the size of the actual pot, like:
    Huge pot: 100%-70%
    Medium pot: 70%-30%
    Small pot: 30-10%
    Tiny pot: 10-0%

    I can not scale only one of the animations from 100 to 0 due to changes in line thickness!

    I think the first step is to “normalize” the different sizes. And then? Any hints, please?

    Roger Maus replied 14 years ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    April 28, 2012 at 3:50 pm

    Assuming that your four animations are the first four layers in a precomp and the precomp is a layer in a comp named “Main Comp”, if you apply this opacity expression to each clip and scale the precomp layer, it should do what you want.


    s = comp("Main Comp").layer(thisComp.name).transform.scale[0];

    if (index == 1){
    min = -99999;
    max = 10;
    }else if (index == 2){
    min = 10;
    max = 30;
    }else if (index == 3){
    min = 30;
    max = 70;
    }else{
    min = 70;
    max = 99999;
    }

    if (min <= s && s < max) 100 else 0

    Dan

  • Roger Maus

    April 28, 2012 at 11:05 pm

    Hi Dan,

    thanks for the quick response.

    It does work for a fixed scale.
    However when it comes to animating the scale, the precomp sticks to the very animation that the precomp started with. It does not switch.

    e.g. the precomp starts of at 100% scale. As time passes by, the scale is going down to 10% – but the animation stays the one at 100%.
    e.g. the precomp starts of at 10% scale. As time passes by, the scale is going up to 100% – but the animation stays the one at 10%.

    The first value is all that matters. There is no live update.

    What should I do?

  • Dan Ebberts

    April 29, 2012 at 1:13 am

    Just a hunch–try it this way instead:


    L = comp("Main Comp").layer(thisComp.name);
    s = L.transform.scale.valueAtTime(time + L.startTime)[0];
    if (index == 1){
    min = -99999;
    max = 10;
    }else if (index == 2){
    min = 10;
    max = 30;
    }else if (index == 3){
    min = 30;
    max = 70;
    }else{
    min = 70;
    max = 99999;
    }
    if (min <= s && s < max) 100 else 0

    Dan

  • Roger Maus

    April 29, 2012 at 1:39 am

    That’s it! Works like a charm! Thank you so much!

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