Guys and welcome to this new lecture about expressions we will focus on simple expressions in After
Effects how to link properties how to link properties with two or three values that we a rate and how
to link rotation was position scale with rotation.
And stories like this.
So let me demonstrate for you here how you can use the expressions in after just a demonstration.
So the animation itself might not be very meaningful but the expressions will be very meaningful to
you.
I want to draw as a rectangle just here a simple rectangle I press control of the net and to put the
anchor point just in the middle.
Now I will draw another one another circle just here just for demonstration purpose.
Could I press control alt and whom to put the anchor point of the letter in the middle.
Now let's create animation for the circle so this is our circle fine.
And this is our square.
We created an image for the circle I placed before position keyframe the position here and go after
one second for example and move it to the side.
That's pretty good.
I can put a couple of frames in between this one up with keyframe it here and moved down from it down
and something like that so we have a nice butt that you can walk.
Yes.
Now we have one set of keyframes for its single path and is doing well.
Now what I want to do is to take the square here and rotate it while the circle is moving.
So if the circle goes fast I wanted to go the rotation to go fast and if the circle go slow the rotation
will go slow.
Now I cannot use parenting here because parenting would not link a rotation to a position that's not
possible at reading position to position.
So I'll come to square and open the rotation.
I press R and R the rotation here that has a single value.
You notice the revolutions here the 0 is a cumulative value of the rotation so it has only one value
and any one value trotted to start writing expressions.
I will point on the stopwatch press and then it and click it will open the transformation working space.
If you want it that's a few meters.
The first one is to enable the expression if you want it on and off.
This is also for the graph to see your expression before and after the expression in the graph.
And they have the pick me up and that's the main element we are going to use and have a smaller row
here like all other small arrows we have seen that will enable you to pick some expressions from the
expression menu.
Of course there is a huge number of expressions here.
And each one of them has its own you know uses but there is no need for you to know all of them just
know the practical ones and not the concept.
And then you can really choose what you want to do.
So to be able to put a value here instead of having transform rotation which is exactly this value I
will use the pick I would highlight everything inside here which is already highlighted.
Click on the big trip and drag.
So now I can choose the whole layer the position and value of the position.
So most probably I want to use one value which is the x value for example of the position of the circle.
That's the horizontal one.
And just release.
Now if you look at the expression here it is not something very difficult it's actually plain English.
If you read this comp.
So it means take from this camp and take from this layer layer called a circle from the transformed
property.
They position zero.
So position is 0 1 not one to remember that in programming it always starts from 0 and then goes 1 to
3 so position 0 is this position for the circle.
So from this comp from this layer from the transform take positions.
And that's it.
You have now linked the rotation to the present position of the circle.
If I run it and if you hear you are your square is rotating with the movement of the circle the position
of the suit.
Now that's pretty cool.
That's not exactly what I want you know the animation just stops and is not pretty cool what I want
to do is force a circle to keep on moving when he comes here at the end.
I wanted to go back.
There is a simple expression I can use.
Now I will come to a position point on the stopwatch press al-Thani and click on the stopwatch.
It will open the expression for position for the circle.
I really don't want to write an expression here.
I want to write a function.
This is a function I Our write loop out and close brackets.
Functions always have brackets.
Now if I click outside it commits and it's OK it has no mistakes.
Otherwise it just showed me a message here where they got the loop out from.
That's very easy I could have come to property because loop out is a function that works on property
and there is loop out here with some parameters that we will see how they work.
Now if foreign Manumission you notice the loop out has made the circle go back what's happening Zackery
that loop out will loop all these keyframes as long as it passes the last frame so when it passes the
Laski frame goes back to the first keyframe and so on.
OK so that is loop out.
Now is it not is that loop out of the other Palamedes I can use.
Now this is not exactly what I want when it comes here it is coming back to the I don't want.
I wanted to come over here and then go back on the same path you know.
If I were to do this with keyframes I am really in trouble I have to duplicate this keyframes I don't
know do a lot of work here.
Sync them.
I'm going to use the parameters of loop out one parameter that is very nice and the name is really funny
is being Ponk.
That makes sense if you ever played ping pong you know the ball goes on one side goes to the next side
and so on.
Let's see how it works now if I play a review here you are going to the left or to the right and then
coming back on the same path you notice the path here is going.
That's pretty cool.
There is another Palamedes I can use here.
I'll show you just for fun.
I will come and try to continue
that's pretty nice.
Now not what happened at the end of last the last keyframe or at the last keyframe is going to take
another path to show you nicely I'm going to put this path just overdye.
OK.
And I will play.
Now it goes and then it continues.
Notice how it's continued when it exited the Laski frame and exit the path it continue in a straight
line.
That's pretty cool by the way.
Let's change our path a bit.
Let's play with it and see what we can do.
So we have it here and we take this one up for example and this one up here which will.
So I'm going to remove continue and write a ping pong again I will open quotes.
Right.
Bing bong close and then I can add another Paromita is which keyframe I would write keyframe number
one.
OK.
Actually it's not the first keyframe but you will see.
Let's take the path so we can see what is going and run a play.
Notice now it is looping just before the Lossky flip.
So the one is 1 keyframe before.
That's pretty cool.
Look at your animation now.
After the Laski frame is this looping between the last keyframe and the keyframe before for the rest
of the composition.
If you write two and we choose our circle now not as it's looping for the last two keyframes and that's
pretty interesting let's remove it.
It's pretty nice.
Pretty interesting and you can have a path and then you can loop it for the keyframes that you want
good.
So I really do that with keyframes.
I don't think I want to go through it.
It's pretty difficult because I have to replicate the path to replicate the keyframes and if there is
any change I have to be very careful about how I'm changing my path here is almost instant.
I can come and play with my path the way I want and the animation will still be pumping and looping
the way I designed it.
That's very cool.
Now this is nice but not so nice.
Let's add a few things.
For example I'm going to add text here.
That's right.
One two three and put the anchor point in the middle of the la control and each one.
And just take the text and use the selection tool and put it under.
Now what I want is the text to be moving with my small circle here.
Fine if I use printing look what's going to happen.
It's going to move with the circle everywhere the circle goes.
That's pretty nice but that's not what I want.
What I want is for the text there to move only horizontally while the ball is going up and down.
So if the ball is moving horizontally the text will move horizontally but it would not move up and down.
How would I do that.
First of all let us remove the parenting and we go to a position of course.
Click on the stopwatch while holding it.
It will open the expression again I'm going to use the clip.
Not I didn't write any code until now.
So I'll take the big leap and go to my circle I say OK I want to go on horizontally.
So I would link it only to horizontal.
Now I want you to draw your attention.
What we have done here is take it to perimeter property and link it to a single parameter not just what
after effects have done let's play first for now is going you know juggling.
Why is that.
Because we require here two parameters to fulfill the position we require.
The horizontal and vertical Yes I don't want to use the vertical one but it took Temperley time.
That's a variable.
It's located the position 0.
Remember we said 0 1.
So it took from this camp this player it took transform and from transformed position 0 but now it needs
to by the balls it duplicate this one.
So this one really we don't want it.
So I have several choices here.
I need to delete this one.
I can just whip it to original and it will work fine.
Not just here you are just going horizontal.
That's pretty cool.
So while the circle is going up and down and horizontal The text is just going left and right.
Or isn't.
If I want to use the transform here and the big whip I could have written value.
1.
So value 1 will beat the value 1 from this property value 0 is the X-axis or the horizontal value 1
is the vertical one.
And I could replace this with the one.
It's good to know.
I prefer that use the equip it's easier the writing value 1 acyclic outside.
Here we are.
Everything is working very fine.
That is called balance.
You know there is only 1 2 3 and is moving it doesn't make any sense.
Let's change this.
Let's go to the text.
Open source text.
We're best alternate and click on the stopwatch when enable the expression.
Not this here because there is nothing to display it give me this red ribbon here with an error message.
This is not working.
Don't worry about this as soon as you write a good expression.
Correct one and then you click outside it will remove all this.
Now what do I want to put in this text.
I'm going to use the whip and take it and put the go to circle.
This is my circle.
I want to put the value of the Oriental coordinate.
That is the X and click simply out.
Here you are.
Now it's moving left or right is giving me the value.
If you can see it nicely.
I don't think so.
Let's make it a bit slower.
So we take all this one plus al-Thani and move it for example three seconds.
Good.
You know this this is a very big figure.
It has so many decimals under it and this is not exactly what you want to display.
So how do we fix that.
That's pretty easy by the way we are going to use another function.
I will come to the beginning of the lay of this game player and so on.
I want to round this one so I'll go to the small row here and go to javascript math.
Don't be scared from javascript math.
Give it big names.
But really it's nothing.
And I'm going to take the math notrump.
So the round function has been existing since the 80s with and it appears in the basic language at this
time.
So we are going to round the value here but not this hard math that.
It got me you know the syntax of the function here.
I need to remove value and close the brackets at the end.
Remember always to close your brackets when you use certain functions or certain Javascript functions.
If I click out look now it is only around that there is no decimal.
That's pretty nice.
OK.
Mine is bigger is big.
It's an example.
What can I do.
Maybe I want to reduce the value.
This is a lot of value here.
Maybe I want to make it half.
If I come at the end here and say divide by half.
Now I'm doing some arithmetic.
I don't call it math.
I call it simple arithmetic in the French system divided by two and click out.
Then it will be divided by two.
And of course there is the point five that is appearing.
That is because after I did the math around I divide it by two.
So it really displayed that value.
But if I wanted to round after division I would put the divided by two inside the math round.
Pretty simple.
Just be careful about the it is at the end.
I click here you are cool now.
So now you have all this and not this we have very few keyframes let's do something else.
Let's take a rectangle for example and just put the rectangle here.
Simple and put the anchor point in the middle of the creek think what I want is when this is moving
the circle is moving left and right or up and down and left and right.
I want the bat the pad here to move up and down only so I come back to the beginning.
Of course I cannot parent if I do parent is going to move all over the place with the circle will come
to my pod.
So we call this path for example.
So were writing a game and I will come of course to the transform and position press and then click
on the stopwatch.
I have the position now what I want to change here is just the y value you know before we change the
X-Files.
So I will use the quip.
I will go down to the circle and now I will choose the y value of course I'm just repeating it but it's
important.
It has taken the y value that position one and replicated so this one we don't want it.
What we can do is write either value 0 or just click on the whip and just choose the x value or value
0.
Now not as what I have done here.
I've just highlighted the text that I don't want or the whatever variable that is here use the pick
up and drop it over the ex-buddy.
And here you are.
It has replaced the value.
I click out and let's see what's happening.
Cool.
So now the pad here is moving up and down with the circle and the numbers are leaving moving up and
right now.
What does all this work is very nice.
Let's take the circle and if I change the path of the circle right then my whole animation will change
and I'm not really using any keyframes.
If I play it here it goes up and down the path the numbers are moving you know left and right.
And it's really following the motion of the path or the speed of the path.
So this is about expressions and this is how helpful they can be.
Of course this is silly example I'm giving you but it's very meaningful if you just understand this
what have we done.
If I choose all my layers turn them up and press you for keyframes I have only one set of keyframes
if I want the whole animation to become slower I press and then it move.
This for example and everything has become so to speak here or even slowly and I can play in between
the keyframes that is loop out one two three four whatever I want.
So if there is changes to be done here it's extremely easy I can just come here and show the path.
Read this keyframe for example.
And now you have something totally different yet the rectangle is still turning according to the speed
of the circle.
Now I didn't lose the parenting abilities.
I can come to elipse and put just an ellipse here put down a point in the middle.
It's not necessary.
And the ellipse to the square but the square is using the expression to move.
Still you can pattern to it and you can also get it if you want.
It would make a lot of trouble but still printing is working.
I want to draw your attention something very important if you choose all your layers and press the relatively
fast it will display all your expressions.
That this is almost English.
And there is nothing you know difficult about it just to get around it to learn how to use the whip
to relink the properties together or link one property to another property and be able to understand
how these things work in the next lecture we will develop on this concept and I will take them one by
one and I will explain.
Thanks for listening.
See you in the next lecture.