ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Can an expression link to another expression?

FAQ   •   VIEW ALL
 Can an expression link to another expression? on Jan 10, 2013 at 12:14:49 am

I have searched and found little to no results to find if I can link one expression to another.

i.e.,

I have over 60 layers that I want to have an expression. However, instead of re-adjusting the expressoion one by one. I'm thinking crazy, maybe there's a way to link one expression to another. So my end results is that I have 60 layers with expressions all pointing to one expression. So that the "Master" expression is adjusted, it affects all links.

Here's my expression;

Vy0 = 500; //initial y velocity (pixels/second)
Vx0 = 100; // initial x velocity (pixels/second)
g = 2500; // gravity (pixels/second/second)
floor = 400;
e = .85; //elasticity
b = floor - position[1];
h = b + Vy0*Vy0/(2*g);
T = Vy0/g + Math.sqrt(2*h/g);
if ((time-inPoint) < T){
y = Vy0*(time-inPoint) - g*(time-inPoint)*(time-inPoint)/2 + b;
}else{
Vy = -(Vy0 - g*T);
while (true){
Vy *= e;
t = T;
T += 2*Vy/g;
if ((time-inPoint) < T){
t = (time-inPoint) - t;
y = Vy*t - g*t*t/2;
break;
}else if (T - t < thisComp.frameDuration){
y = 0;
break;
}
}
}

Cool very cool! I'm excited... Just cause

 Re: Can an expression link to another expression?on Jan 10, 2013 at 12:45:01 am

A better approach is to use Expression Controls which are linked to the variable values in the expression.

A simple example:

A Null object with an Expression Control slider named "Offset".

Two layers with a position expression that reads:

offset = thisComp.layer("Control").effect("Offset")("Slider");
[transform.position[0],transform.position[1]+offset]

Changing the value of the slider affects both layers.

Here is an example: 5200_expressioncontrol.aep.zip

 Re: Can an expression link to another expression?on Jan 10, 2013 at 1:14:19 am

Well I did do that and I was able to make several layers work, howeverw I got an error.

Here's my script

Vy0 = thisComp.layer("Null 1").effect("y Velocity")("Slider"); //initial y velocity (pixels/second)
Vx0 = thisComp.layer("Null 1").effect("x Velocity")("Slider"); // initial x velocity (pixels/second)
g = thisComp.layer("Null 1").effect("Gravity")("Slider"); // gravity (pixels/second/second)
floor = thisComp.layer("Null 1").effect("Floor")("Slider");
e = thisComp.layer("Null 1").effect("Elasticity")("Slider"); //elasticity
b = floor - position[1];
h = b + Vy0*Vy0/(2*g);
T = Vy0/g + Math.sqrt(2*h/g);
if ((time-inPoint) < T){
y = Vy0*(time-inPoint) - g*(time-inPoint)*(time-inPoint)/2 + b;
}else{
Vy = -(Vy0 - g*T);
while (true){
Vy *= e;
t = T;
T += 2*Vy/g;
if ((time-inPoint) < T){
t = (time-inPoint) - t;
y = Vy*t - g*t*t/2;
break;
}else if (T - t < thisComp.frameDuration){
y = 0;
break;
}
}
}

I have the expression working on layers and comps. It also isn't applied to certain Layers or Comps. Any light for this error?

Cool very cool! I'm excited... Just cause

 Re: Can an expression link to another expression?on Jan 10, 2013 at 1:50:08 am

This is a divide by zero error, your slider has a value of 0 you need to account for that in the script so the value is never 0 and will not produce the error.