ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Multiple Expressions on one attribute

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
John Pritchett
Multiple Expressions on one attribute
on May 29, 2019 at 6:25:10 am

Hi Legends.
Im sure this has been asked before, but I cant find anything specific.
I need two Opacity expressions on the one layer. The second expressions is decided from the first.

See below. The first is using a Comp marker to decide the time of the transition off (opacity)
The bottom line is using a slider to determine if this layer can be seen at all. (using opacity)
Now, the bottom line is overriding the first calculation.
Any help appreciated!

holdTime = thisComp.marker.key(1).time-1.8;

m1 = 1; // 1st hold marker
m2 = 2; // 2nd hold marker

p = thisLayer;
t1 = p.marker.key(m1).time;
t2 = t1 + holdTime;

if (time < t1) { t = time }
else if (time < t2) { t = linear(time,t1,t2,t1,p.marker.key(m2).time) }
else { t = p.marker.key(m2).time + (time - t2) }

valueAtTime(t);


if(thisComp.layer("Control Panel").effect("NUMBER OF LINES 1, 2 or 3")("Slider") == 3) value else 0;


Return to posts index

Tomas Bumbulevičius
Re: Multiple Expressions on one attribute
on May 29, 2019 at 8:02:59 am

Hey John, first things first - are you sure that first part works as expected without the second at all? It doesn't seem to be like it, because 'Time' is being interpolated to 'Time', with linear expression. And even though its passed to 'valueAtTime', that value isn't actually opacity's range value, nor a proper change.

Is it really as it should be in your case scenario? Assuming this should be some sort of opacity fade based on the markers?

Find out more:
After Effects Tutorials: motion design, expressions, scripting.
Boxer - Dynamic Text Boxes Template with a Live Preview


Return to posts index

John Pritchett
Re: Multiple Expressions on one attribute
on May 30, 2019 at 6:23:30 am

Hey Tomas.. Yes, things are working correctly as I want without the last line...
What I am attempting, is to have a position and opacity animation (simple 2 keyframes on each attribute) The comp marker is dictating when the animation finishes...all working fine so far.

I need to have another script to switch visibility on or off triggered by a Slider (if number 1 its off, if number 2 its off, if number 3 its on)HOWEVER. the opacity is being used in the animation... so I guess I need to use valueAtTime somehow...


Return to posts index


Tomas Bumbulevičius
Re: Multiple Expressions on one attribute
on May 30, 2019 at 8:49:59 am

Hey John, thanks for confirmation. Actually, I just tried to test this alone based on information provided, with some markers in comp as well as layer markers. Here is what I get, the same way as I 'debugged' it in my mind:

When this case happens: else if (time < t2) { t = linear(time,t1,t2,t1,p.marker.key(m2).time) }

1. Interpolation is introduced. t becomes a numeric value from interpolation. Meaning, if t1 is at 1st second, interpolation actually returns value in the range of [1..p.marker.key(m2).time].
2. Here is what I don't understand here - what opacity values you are actually getting in such case.

Maybe my setup of marker timestamps just didn't match the logic you have, but this turns out to be wrong opacity interpolation on my end.

As a side note, I would strongly recommend writing expressions with full syntax. Of course its a matter of preference and getting used to it, but readability is clearly more better from a first sight 😇

On a different note, sometimes it is easier to apply 'Distort > Transformation' to have another level of control via different transformation option (where you could apply different controllers over it). Its a workaround though :)

Find out more:
After Effects Tutorials: motion design, expressions, scripting.
Boxer - Dynamic Text Boxes Template with a Live Preview


Return to posts index

Oleg Pirogov
Re: Multiple Expressions on one attribute
on May 29, 2019 at 8:23:14 am

Won't changing the last line to
"if(thisComp.layer("Control Panel").effect("NUMBER OF LINES 1, 2 or 3")("Slider") == 3) valueAtTime(t) else 0;"
get you what you want?


Return to posts index

John Pritchett
Re: Multiple Expressions on one attribute
on May 30, 2019 at 6:20:09 am

Thanks Oleg, This is very strange. I added your suggestion (to the bottom of another attribute, but this will give the correct outcome)...and it works...however its throwing up an expression error...
This is what I have now

if(thisComp.layer("Control Panel").effect("TEXT ALIGINMENT RIGHT LEFT")("Checkbox") ==1) 0 else value;
if(thisComp.layer("Control Panel").effect("NUMBER OF LINES 1, 2 or 3")("Slider") == 3) valueAtTime(t) else 0;

Basically asking a checkbox to turn opacity on or off, AND a slider to turn opacity on or off..
This is for a 3 line Lower Third.


Return to posts index

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