ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

simplify a whole array of expressions

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Kabo Lam
simplify a whole array of expressions
on Mar 13, 2017 at 1:27:15 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


Return to posts index

Xavier Gomez
Re: simplify a whole array of expressions
on Mar 13, 2017 at 9:02:42 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


Return to posts index

Kabo Lam
Re: simplify a whole array of expressions
on Mar 14, 2017 at 10:43:17 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<counter; 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;

thanks!

Always learning


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]