Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions simplify a whole array of expressions

  • simplify a whole array of expressions

    Posted by Kabo Lam on March 13, 2017 at 1:27 pm

    Hi,
    I was hoping someone could help me with a expression i’m working on. I’m trying te make a message pop up box like whatsapp, if a new message pop up from below, the previous messages slide up. I use a null controller to control the y-position of all de messages ( rectangle shape layers). And this is what I have so far.

    As you can see, the only difference between a,b,c and so on is the index number.
    I think instead of the “linear(thisComp.layer(index+X).transform…” it can be a lot shorter and cleaner, something that can look at active.layers and fill in the number automatically.

    I hope i’m explaining this right and someone could help me?

    a = linear(thisComp.layer(index+1).transform.scale[1],0,100,transform.yPosition,transform.yPosition-thisComp.layer(index+1).content("Rectangle 1").content("Rectangle Path 1").size[1]);
    b = linear(thisComp.layer(index+2).transform.scale[1],0,100,transform.yPosition,transform.yPosition-thisComp.layer(index+2).content("Rectangle 1").content("Rectangle Path 1").size[1]);
    c = linear(thisComp.layer(index+3).transform.scale[1],0,100,transform.yPosition,transform.yPosition-thisComp.layer(index+3).content("Rectangle 1").content("Rectangle Path 1").size[1]);
    d = linear(thisComp.layer(index+4).transform.scale[1],0,100,transform.yPosition,transform.yPosition-thisComp.layer(index+4).content("Rectangle 1").content("Rectangle Path 1").size[1]);
    e = linear(thisComp.layer(index+5).transform.scale[1],0,100,transform.yPosition,transform.yPosition-thisComp.layer(index+5).content("Rectangle 1").content("Rectangle Path 1").size[1]);

    z= [a+b+c+d+ e];

    z

    Always learning

    Kabo Lam replied 9 years, 2 months ago 2 Members · 2 Replies
  • 2 Replies
  • Xavier Gomez

    March 13, 2017 at 9:02 pm

    Your expression is 5 lines long, it cant really be much shorter.
    With a looop can achieve less text though:

    z=0;
    for (i=1; i<6; i++){
    L = thisComp.layer(index+i);
    z += linear(L.transform.scale[1],0,100,transform.yPosition,transform.yPosition-L.content("Rectangle 1").content("Rectangle Path 1").size[1]);
    };
    z;

    You have to specify other layers either by their name, either by their index though.
    There is no such thing as “thisComp.activeLayers”.

    Xavier

  • Kabo Lam

    March 14, 2017 at 10:43 am

    Yes, this is what i’m talking about. The reason i’m asking is because i want to make the project like a template, and the number of layers varies, it can be 5 lines, maybe 15. I did find something like a counter (text source), it shows the number of active layers at current time:

    n = 0;
    for (i = 1; i < index; i++)
    if (thisComp.layer(i).active)
    n++;
    (n)

    so it would look like this:
    z=0;
    for (i=1; i
    thanks!

    Always learning

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