2 Replies Latest reply on Oct 6, 2015 7:49 PM by David Mattingly

# Scaling expression help

I am not an expressions master, but I think I want to do something simple, but I can't figure out how to do it. I want to have one layer take one tenth of the size of an animated scaling layer, then add back in the original size of the layer,so that the second layer is scaling up one tenth of the speed of the original layer.

So I pick whipped the scaling of the second layer to the first, and get this:

thisComp.layer("multiplanemountains.jpg 2").transform.scale

Now I want to have this layer scaled  to 1/10  the scale of the controlling layer, so I added to the expression to divide it by 10:

thisComp.layer("multiplanemountains.jpg 2").transform.scale/10

I still need to restore the original size, so that it is just 1/10 larger than the controlling layer , so I thought I should be able to add 100, so I do this:

thisComp.layer("multiplanemountains.jpg 2").transform.scale/10+100

But it only adds the 100 to the horizontal scale, not the vertical. I tried bracketing it off, but after effects says this is a bad expression and won’t accept it:

thisComp.layer("multiplanemountains.jpg 2”).(transform.scale/10)+100

I tried bracketing off the 100 and giving it x and y values like this:

thisComp.layer("multiplanemountains.jpg 2").transform.scale/10+(100,100)

It still only scales the horizontal value.

I know I have to tell it to add the 100 to both the x and y, but I can’t figure out how to do it. Can anyone help me out?

• ###### 1. Re: Scaling expression help

You are not getting the array function. Maybe this will help. All properties that have more than one value are arrays. An array is written inside square brackets. For example if you write this as an expression for scale [50, 75] then the layer will be scaled to 50% in X and 75% in Y. If you type .scale[0] in an expression then that will return the X value of scale. .scale[1] is the Y value, and if you have a 3D layer then .scale[2] returns the z scale (this makes a difference in the layer's position when scaling a 3D layer)

Let's look at your expression and set up some variables. I take it that multipleanemountains.jpg 2 is the master layer. Personally I'd rename that layer Master. Let's start by improving your syntax and simplifying the calculations by identifying the property you want to work with as a variable.

m = thisComp.layer("multiplanemountains.jpg 2").transform.scale;

Now you can do your math on variable "m" and it's a lot simpler. This is where I get into some trouble with your request and your math. Let's take your original theory. Divide by 10 then add 100. The correct way to do that would be to write the expression like this:

m/10 + [100, 100];

Here's the result. If the master layer is 100% then the slave layer will be 110%, but if the original layer is 200% then the slave layer will be 120%. I don't think that is what you want. What I think you want is to multiply the master layer by 1.1 so that the slave is 10% bigger than the master. You would write that like this:

m * 1.1

Now when the master is 100% the slave will be 110% and when the master is 200% the slave will be 220%

• ###### 2. Re: Scaling expression help

Rick--

That did it! Thank you so much for taking the time to write such a complete and thoughtful reply. I struggled all day to figure this out, and your post extended my understanding of expressions.

David Mattingly