ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# how to get the opposite?

FAQ   •   VIEW ALL
 how to get the opposite? on Mar 25, 2009 at 2:59:30 pm

Hi,

I got a question. Propeply very simple but I just dont understand a thing. How do you get some layer property to get the opposite value of another? e.g:

the scale of my solid is 100% and the 2nd solid is -100%. how do I get the scale of my 1st solid to get to -100% if I keyframe the other to 100%??

Sounds easy. Sorry for my poor english but I hope you guys understand my question.

cheers.

 Re: how to get the opposite?on Mar 25, 2009 at 4:07:35 pm

Just apply a Scale expression like this to the 2nd solid:

-thisComp.layer("1st solid name").transform.scale

Dan

 Re: how to get the opposite?on Mar 25, 2009 at 4:57:03 pm

What I'd like to know is this:

What expression is needed to let one layer shrink the size the other layer grow?

 Re: how to get the opposite?on Mar 25, 2009 at 5:06:03 pm

More like this then, maybe:

s = thisComp.layer("1st solid name").transform.scale;
[100-s[0],100-s[1]]

Dan

 Re: how to get the opposite?on Mar 25, 2009 at 5:33:19 pm

Hi dan,

Thnx for the help. But it still doesnt do what Im looking for. Solid 2 scale's along with Solid 1 but it needs to go the oposit direction, like this:

s1 = 100
s2 = 100

s1 = 150
s2 = 50

s1 = 200
s2 = 0

etc..

 Re: how to get the opposite?on Mar 25, 2009 at 5:42:16 pm

Try this:

s = 200 - thisComp.layer("1st solid").transform.scale[0];
[s,s]

Dan

 Re: how to get the opposite?on Mar 25, 2009 at 7:47:52 pm

Thnx man. That worked out great!

 Re: how to get the opposite?on Dec 27, 2012 at 4:28:28 pm

Hi Dan, i'm just looking for something similar, but in this case, with "y" position, to animate two eye lids in a bug, in opposite positions with an Expression Control.

Gustavo.

 Re: how to get the opposite?on Dec 27, 2012 at 4:56:02 pm

Assuming you have a Slider Control on a layer named "controls", it would look like this for the upper eyelid:

s = thisComp.layer("controls").effect("Slider Control")("Slider");
value - [0,s]

and this for the lower:

s = thisComp.layer("controls").effect("Slider Control")("Slider");
value + [0,s]

Dan

 Re: how to get the opposite?on Dec 27, 2012 at 5:33:06 pm

Thanks Dan! You Math Monster!

 Re: how to get the opposite?on Jun 7, 2016 at 8:47:52 pm

Hey Dan,

Is there a command name we can use in expressions to tell it to do the opposite of what the original layer its pick-whipped to? Meaning, if LAYER 1 is moving up, and I want LAYER 2 to do the direct opposite (go down at the same speed while being connected to LAYER 1 via an expression), what command name should I use for that?

This is just one example, but essentially I'm looking to be able to apply the opposite/inverse expression command to many other situations. Thanks!

 Re: how to get the opposite?on Jun 8, 2016 at 12:01:16 am

There isn't anything like that. It's actually kind of tricky, because "opposite" means different things for different properties, and can even have multiple meanings for the same property. Position, for example, needs a reference, which can be a specific point (center of the comp maybe), or the reference layer's starting position at time=0.

Similarly, for Scale, opposite might mean s2 = -s1, or it might mean s2 = [100-s1[0],100-s1[1]].

Dan