A beginner's introduction to After Effects Expressions | Nash Vail | Skillshare

Playback Speed


  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

A beginner's introduction to After Effects Expressions

teacher avatar Nash Vail, I write and draw and design and code.

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

9 Lessons (1h 38m)
    • 1. Introduction

      2:45
    • 2. Before we begin

      1:51
    • 3. Variables

      10:37
    • 4. Position & Arrays

      13:03
    • 5. Traversal using the Dot Notation

      12:40
    • 6. value & valueAtTime

      18:36
    • 7. Putting it all together - 1

      10:14
    • 8. Putting it all together - 2

      19:21
    • 9. Conclusion & What's next?

      8:26
  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

70

Students

--

Projects

About This Class

d2845754.gif

If you have ever used (copied & pasted) After Effects expressions, or heard of it but never had a chance, or couldn't find a resource to get your feet wet, this is it!

Welcome to my class about Expressions! Expressions have a reputation of being daunting but Expressions are also extremely versatile and there's a variety of things you can accomplish with them. The goal of this class is to gently hold your hand and bring you inside the world of Expressions, to make Expressions less daunting and open them up for your exploration and experimentation.

As evident from the title, this class is for Beginners. The class is divided into 9 lessons. Lessons 3 - 8 form the core, where I introduce you to the most basic concepts that you'll carry as you dive deeper and deeper into the world of Expressions.

And in case I didn't mention, no prior programming experience is required to take the class, let's get started!

Meet Your Teacher

Teacher Profile Image

Nash Vail

I write and draw and design and code.

Teacher

Hello, I'm Nash. I am a Developer, Designer and I absolutely love teaching. I have been a professional in this field for over 6 years. I have gotten chance to work with some great companies and equally awesome open source organizations including the jQuery foundation. I am the co-founder and head of design @ Devfolio

I am a huge proponent of sharing knowledge and I try to do that through my blog and other sites like Smashing Magazine where I have a few articles up. Here in Skillshare, my goal is to share the same knowledge through videos.

If you found what I taught valuable, give me a follow, tweet to me, I am always up for a great conversation. Happy Learning!

See full profile

Class Ratings

Expectations Met?
  • Exceeded!
    0%
  • Yes
    0%
  • Somewhat
    0%
  • Not really
    0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. Introduction: Here's the deal. I've learned a ton about after thanks and animation from some great designers, animators and illustrators, right here on Skillshare or on YouTube or wherever I've found the resources available. And within these tutorials and resources of course, have come across After Effects expressions. And I know just how powerful they can be more often than not, I've found that these great animators and designers who have learned a ton from tweet expressions like magic spouts. And there's of course, reasons for it, since expression is so heavily based on programming, not every animator is also a programmer. So this detachment of profession is one of the reasons. Therefore, for the most part, all I get to learn from these tutorials is that, hey, here's the expression, copy it, paste it here. And this is what it does, how it does, it doesn't really matter. And honestly, for the most part, it doesn't. You're able to create beautiful animation by copying and pasting some expression from your collection. And that's that. But this mindset and workflow perpetuates making each new generation of animators treating expressions just as magic spells and nothing more. But of course, we both know that expressions are not magic spells. They are beautiful. They are one of the most beautiful forums of code to me. And often there's a debate about what programming language or someone you do programming. Hughes and I'm a strong believer. After Effects expressions are the best way to introduce somewhat your programming, mainly because it's visual. You don't have to create and carry around a mental model in your head, you can see things change and move on the screen as you type. And that visual element makes it so much easier to absorb the concepts of programming. But I digress, this class is about peeking behind the curtains and understanding how expressions actually work so that you can not only have a library of expressions, but also understand how each of them function. And when you understand that you can make your very own expressions and also tweet the ones that you find online to meet the expression work, how you would actually want it. Besides the benefits of knowing how expressions work, the pure joy of understanding something that hasn't been Elian to you is truly satisfying. And that is my, one of the top goals of this class to remove the mysticism that surrounds expressions After Effects, expressions are based on the JavaScript programming language. If you have any prior experience with programming after come out clean and say that you are going to find a big chunk of this class, super boring because I'm going to teach everything from the ground up, everything from scratch, everything from the fundamentals, and everything from the very, very basics. So enough of me talking, let's get to teaching. 2. Before we begin: Okay. If this is your first time hearing about After Effects expressions, give me your two minutes or one minute, but definitely less than two to give you the very basic idea of what After Effects expressions are the most basic or the dominant way of animating something in After Effects. As by keyframing properties, you want something position to change. You go into the position property under transform, you add a keyframe. You move ahead into time and you know, change the position of whatever you were animating and bam, there is the animation. When do I animate and other property go into the property, Let's say rotation, add a keyframe, move event in time, decrease the value or increase the value. That's another keyframe. And there you go. There's another animation, the after-effects gods after. This could have been. Yeah, there you go. That's pretty much it. Use properties and keyframes and make cool stuff. Yep. But no, they gave us expressions and we should be very, very grateful for it. Expressions allow you to rig and animate all of the keyframe or bulk properties. Now the expressions that you ride is essentially writing code. And in this class we're going to make sense of it before proceeding with the rest of the class. The only two things you need to know is this number 1. To add an expression to a property you Option plus click on Mac or Alt plus click on Windows on this stopwatch icon that is presented beside a properties name. So there you go. This is how you start writing and expression. The second thing that you need to know is that any text layer on the canvas has a text and source text property that stores the data that the text layer is holding. For example, this text layer is holding the data text layer, and that text is stored inside the source text property. If I change the value to something like my name, The data is now my name, and this is the data that the source text layer is holding. Okay, with that, we are all set to dive right in. 3. Variables: Okay, So I've just fired up After Effects and let's get started with the first lesson of this class. Now rather you are super familiar with this interface or this is all just unknown territory to you. It doesn't matter when you fire up After Effects and close this dialogue that pops up, you will see two squares at the center, new composition and you composition from footage. What do you want to do is click on new composition. You can give any name you want in the composition name field here, it's usually filled with calm followed by a number for us it as calm one and that is fine with those right now. You can change the width and the height of the composition here you want. If you're having trouble adjusting the width and the height, make sure that lock aspect ratio is unchecked. I'm going to give it 2000. By 2000. It'll make the frame rate of 24 frames per second and the duration five seconds, okay? And I'll also give it a background color of black. All right, so all of these settings, it really matters when you are making something for, let's say Instagram or a different Vimeo or YouTube video. But for now, I'm this lesson and this composition, it will be just used to tell or TDD some things to you. So all these settings don't really matter. And moreover, if I click OK, those settings are not set in stone. I can always press Command K on Mac or Control plus K and Windows to bring up the settings again. And I can change things as required. Okay, now we have a composition, now the center, and this is the interface, this is the After Effects interface. Yours will be more or less similar to this. But anyway, I'll be explaining every single panel or every single thing that we interact with. So our rest easy and let's get started. One other thing that I wanted to mention is that it has confused me a bit a couple of times. Is this button right over here? If you're not seeing this black color, if you're saying something like this, you want to click on it to toggle the transparency, okay, for this one, make sure that the black is visible. Now the first thing that I want to do is add some text on the canvas so I can select the type tool from over here by clicking here, or use the shortcut Command T to bring up the type tool, then click anywhere and start typing. I'm just going to write some text, okay, and I can get out of the editing mode. I'll click on the Selection tool, and there you are. Now I can select the text and move it around. The next thing that I wanted to do is come here in the timeline and select this layer that says some text. And I'm going to press Enter and rename this layer to debug layer, since we are not going to use this layer for animation, but just use it to show how our expressions is working. And also besides the layer name, you will see the chevron pointing to the right or this right arrow. And you can click on it again to unfold a lot of different animatable properties. All right, but the only thing that we're concerned with in this lesson, in this property called source text, which is nested inside text. Now, here's the cool part. If I believe you already know about it. If you know bad, even a little bit about aftereffect expressions that on Mac you can hold Option and click on this stopwatch icon or hold Alt on Windows and click and open up the expression editor ridges right over here. Okay? And the first thing that I want to do here before we start writing any expression is go to After Effects and then preferences. And from preferences, select scripting and expressions, okay? And this is more of a personal preference, but I just wanted to put it out there because by default the font size is 12 and there is a different theme selected. So you can increase the font size to 14 and then choose after-effects, high contrast for the theme. And this just makes the expressions a lot more readable than you were typing. Alright, let's get over here. We don't need whatever the hell there is. I'm just gonna go ahead and delete everything, okay? And what I'm going to do is hit this key to add quotation mark and then type in hello comma world and then close this with another quotation mark. Now if I click outside, you can see that this text shows right over here. You just wrote your very first expression, or I hope you did. If you're following along now, a few important things. Number one, you will notice that the quotation marks that we typed over here are not visible in the text here. So what the hell? Let's remove the quotation marks, right? Because there are not really serving any purpose. So I'll get rid of it but run into some error. Okay, let's see how bad we just remove comma world and just, let's just write hello. How about that? Still, there is an error which says that hello is not defined. Well, this ever brings us to our very first concept of this lesson, which is variables. Now, broadly speaking, okay, programming is about data and the manipulation of that data. And how do you manipulate or play around with that. You do that using commands that the computer understands. And to read commands the computer looks for is something called keywords, okay. Which are the words or sentences or unique combination of brackets, numbers, et cetera, that the computer can make sense of and understand. So when you write just hello or just comma hello world to the computer, it doesn't understand what's sort of command it is, and it just turns it stands up and gives us an error. So we have to tell the computer that, hey, hey, listen, we're not giving you a command with Hello world, okay, we're just giving you some data, right? So notice a difference between data and command, right? We have to tell the computer that we are giving you data using helloworld and just tell the computer that it's the data. We have to wrap it in quotation marks. Yeah, that's what we did with just wrote Hello with a computer. Didn't understand. So I'm going to just go ahead and wrap it again into quotation marks and serve it as a data. So the aftereffects expression computer compiler, whatever takes this data and assigns it to the source text property. And that is what is visible in the Canvas. And obviously words and sentences like this is just one type of data. Okay, so it's important to understand that as just, just one type of data. That data type that makes up words and sentences is called string data type. There are other types of data, of course, for example, one says data type that we will learn about later is called the number datatype. The After Effects expressions are based on a programming language called JavaScript. So if you go to Mozilla Developer Network, which is a great documentation, a resource for JavaScript. You can see the definition of string, which is strings are useful for holding data that can be represented in text form. And that is all you need to know for now. Now it so happens that in a program that the same data is needed at multiple places in a program, okay? And we don't want to write the same data again and again. So we need a way to store the data into something and tell the computer that, hey, if you need this data, you can find it here. Okay? And this storing of data is done using the concept of variables. Now the utility of variables wouldn't be entirely apparent right now with what we're doing, you will see how useful variables can be and how it makes expressions more readable and easier to write and understand. Now, the way you make a variable in after-effects expression is like this. Your verdict lead, which is a keyword, which is again a command, something that the computer understands. You write lead followed by the name of the variable, okay? And we put the name over here. Then we write equals and put in the data that we want to be assigned to the variable. So here I will just write Hello World. So again, let name of the variable equals and the data that you want the variable to hold. But hold on. There are some rules that you have to follow when you are naming the variable, which are number 1, that a variable name cannot start with a number. All right, that's number one. Number two, the variable name should not contain spaces. Okay, so how do you write variable names that, you know that has multiple words in it? Let's say, for example, that I want to name this variable texts to show I cannot use it. I cannot use this variable name because this will run into an error because we have spaces. So there are different techniques. The first technique is that you can put in underscores instead of the space S. And this will create a new variable without any errors. Something that I like to do is use camel casing in which you capitalize the first letter of each word, sounded like this, and this also creates a variable. The other rule is that the variable names should not contain special characters like stars, ampersand, dollar signs, et cetera. Though it can contain an underscore it like I just showed you, right? And also, you cannot start a variable name with a special character. Just started with a character which is from the alphabet, okay, number to the variable names should not be a keyword or command that the computer is looking for. All right, So for example, like I showed earlier that lead is a keyword. If I named this variable, let again at we will run into an error because this time we used reserved keyword, okay, So you have to create your own variable name and make sure that it is descriptive. So texts to show is a descriptive variable name because this is a text or string that we want to show on the Canvas and we have put it into a variable and then leaving this expression as it is, but it won't do anything and show on the screen because all we did was declared a variable. Now remember that the property you are writing an expression for it. For example, I'm writing an expression for source text right now. The property you are writing an expression for it can accept several different data types. And string is what are the data types that source texts excepts. So in the expression window, if I can call expression window or expression panel right over here, you can do all the calculation that you want or anything that you want over here, whatever you want. But you have to make sure that in the end, you leave the expression panel with something that can be assigned to the source text property, because right now you see we are just a cleaner variable. So what we will do is again write the variable name so that the compiler reads, okay, Here is some sort of data that I can assign to source text. And it will again show it right here in the Canvas. And I can change the data that text is show holes. For example, I can simply write my name and again, it will be updated in the Canvas. Alright, and this was your very gentle introduction to expressions, programming and variables. And I hope you understand the concept. There is no homework for this lesson. We will continue in the next video where we will learn about how to manipulate a position of an object using expression. And I'll see you then. 4. Position & Arrays: Okay, So welcome to the second lesson. And in this class, we just scratched a little bit of the surface about expressions. In the previous video, we wrote something very, very trivial, not really useful in the whole scheme of things, but a nice introduction, a gentle, I think it's a very, it was a very gentle introduction. And slowly, I'm trying to push you into more and more complex expressions. Okay? So now at this point, you know how to create a variable, okay? You know how to do that, right? Let followed by the name of the variable, you write the equals sign and then you put some data over here that is assigned to this variable. Now there are certain rules that I also told you about, about variable names. Those rules are not something that you'll have to remember. I mean, you'd get used to it as you go ahead and try to write more expressions, okay? And now you also know that a string is a data type that can hold text. And you tell the computer that you're using a string data type by wrapping the data into quotation marks. Now, like string is a data type that can hold texts. There is another data type we need to discuss, and it's quite important one and this datatype called number. So let's go into our after-effects again, and let's try to do a few things. So I've got the, pretty much the same setup as the previous video. We've got a text layer and I've called a debug layer. And like I mentioned in the previous video, you can go inside these foals, go to text source text option, click on Mac or Alt, click on Windows, and then you can write some stuff here. So let's go ahead and write a number here. Let's say like 23. And 23 is visible here without any error because 23 is a number data type and the computer understands that without us needing to tell it with quotation marks. Okay? And more than that, I can also do some simple arithmetic operations. You're like 23 plus 13, and it'll be shown 36 here. And again, just so that you remember anything that is here, the property expects some sort of data you're going to assign to itself. And then it is shown here in Canvas. And again, you can do all sorts of different mathematical symbol arithmetic operations like multiplying this by two and doubling the number and stuff like that. And then number of manipulations are actually quite important and aftereffects because all of these properties under transform like position, scale, rotation, opacity, all numbers. The first application of number data type that we're going to use is in manipulating the position of something into Canvas. Now anything that's on the canvas or in this black area or in the composition. It will have, if you unfold it, it will have transform, and then it will have position. And position is made up of two numbers, x. The first one is x and the second one is y. X basically means the distance from the left edge of the canvas, Okay, from here, this is the x distance and y is the distance from the top of the canvas, k. This is the blind distance and this is the x distance. And one important thing to note here that each of these distances of x and y is measured to the anchor point of that object. What is an anchor point? Well, you know, I hope, you know, I'll give you a short explanation though. I'm pretty sure that you know what an anchor point is. So this is the anchor point, okay? This is right over here, this little cross hair that you see. And you can change the position of the anchor point by clicking over here on this tool, which is the pan behind tool, and then drag it around. You can hold Command to snap it and the corners. So what the anchor point does is any transformation that you apply like for example, position, like I said, is measured, measured from ranked over here to the anchor point from each of these edges of the canvas. Okay? So if I increase the X value, right? You can see that moves to the right. And if I increase the y value, it actually moves, moves, that moves down. So this anchor point is basically what's moving and it's moving the entire object and in position It's not very apparent. But let's see if I rotate it, you'll see it will rotate around the anchor point. And if I move the anchor point to over here, you can see that it'll rotate around here. So that is what something that I wanted to make it very clear is that the position of something as calculated to the anchor point of that very object. So all in all position of any object on the canvas, it will also have an anchor point can be represented using two numbers, right? Any, anything on the canvas, the position if it can be represented using two numbers, x and y, are often written like this and this is what there is here and the position properties x and y. And if we want to manipulate each of these numbers individually, what you can do is right-click and then click on separate dimensions. It's often useful when you're writing expressions. Dad effect only. Why or only the exposition. But right now, we don't need that. We will need this later. So we'll go into that. I just wanted you to know that you can also split each of these and animate them individually or write expressions for them individually. So I'll press Command Z and go back to the non splitted, non separate at version of the position. Now before we get into manipulating the position of something on the screen using expressions, I want to talk about an important concept called arrays. Now, like I said before, in programming, there is data and then there is manipulation of that data. Okay, just a quick reminder, keep that in mind. An array is something what is called in programming data structure. There are definitely more data structures in programming, but array is the first data structures that programmers learn and is the most simple one. But what is a data structure? Now, I'm going to give you a very bookish definition, no data structure. And I have to do that before I can get into the practical details and everything falls together and make sense to you. So here, people's attention. So a data structure is a way of organizing data and this is important in a data structure is a way of organizing data, says that it makes it easier for a programmer. So easier is again, a keyword, something important to keep in mind, easier for a programmer to access and manipulate data. And we know that programming Broglie is about data and manipulation of that data. And data structure is something that facilitates easier access and manipulation of data or sensory. We're talking about arrays. We can just remove data structure for him over here and just write array, okay, for now. So array is a way of organizing data, okay, still fits and it makes it easier to access and manipulate data. Okay, That's the book is definition. But now let's get into programming and writing some expressions and learn more about it. And it will make much more sense than reading something from a black screen. Now I'm back into After Effects and I'm in the debug layers source texts expression panel. And here I'm going to show you how to create a new array. The way you create a new array is very similar to how you do with a variable, or, I'm sorry, how you create a variable. So you start out with our writing let, and then I'll choose a name for this array, and I'm going to call it test array and then equals sign. Now instead of putting some data here, instead of writing, let's say hello, which is a string data, or 23, which is a number data. I'm going to go ahead and write opening and closing square brackets, okay? And now inside these brackets I can fill it up with as many different data that I want. The only, the only condition is that each of that data should be separated by commas. So here's what I mean. I can go ahead and put, let's say some numbers, 32, 1809, 96, I can write, okay, hello, I'll put up some texts there too. And seeing that how each of these data is separated by a comma, okay, right, right over here. And as of now, nothing is visible in the Canvas again, because I haven't given it something to assign to the source sex poverty. So let's just go ahead and write test array. And I'm going to go ahead and click outside. And right here you can see that it prints out the array as it is. Now, here's the cool part. What if I just wanted to access One data from this entire array? I can do that by using the concept of array indices. And here's what it is. So here's the array that we declared. We wrote let that be rode the name of the array. And then we put a bunch of data inside these two square brackets. Now each data, each of these data that is inside the array has an index associated with it. The first data inside the array has the index of 0, the second the index of one, the third the index of two, and so on and so forth. So if I wanted to access just one of this data and AI habits index, I can do that by doing this. I'll write the name of the array. So I'll write an open square bracket. I'll write the index of that data and then I'll close it, which basically means I'm accessing the data at index one. The one important thing to remember here that can often slip your mind is that indices inside an array start with the number 0, okay, starts with 0 and not with one. So let's get back to After Effects and see if that works. So right now I have test array with just a science test or revalue do source tags and it shows everything that is inside this array. What if I just wanted to access, let's say 96. So the index of 1906 as 0, 1, 2. So it's indexs too. So I can write. And there we go. Just 96 is visible. Then if I write index three, I'll get hello visible. If I index four, I should run into an array, sorry, into an error because there is no data there, okay, just shows nothing. That's cool TO. So again, if I want to access, I can put an index of the data there. Okay, so an array is useful when we have to have a collection of data instead of just one single piece of data, okay? And you know that the position of an object is made up of two numbers, x and y. And an array is a perfect way of representing the position, which is basically using an array of two numbers. The first one is x and the second one. Why? Okay, So let's get back to After Effects and I'm going to clear everything here. I'm in the expression writing panel of source text of debug layer and I'm going to write a bunch of code or you're okay and you will not understand any of it because the concept of whatever code is going to be red and it will be explained in the next video. But just stay with me for now. So I'm going to write a bunch of code. Now, this code that I've written here basically targets the position property of this layer. Okay, and as I will click out, you will see what gets assigned to source text and as a result gets displayed on the canvas. So I'm going to click outside and if some big number. So let me go ahead and decrease the font size a bit, OK. And you can see that it is basically as I'm moving it since the, since it's directly connected to the position property as the position is changing, so the number is updating. But what I want you to notice is that this is the number, right, for a 2.840029 comma 1073, which is basically this part over here is the x value, and this part over here is the y-value. Okay? And this entire number, this entire number represents the position, okay? And did just to show you that it is an array, what I will do is I write an opening and closing square bracket and type in the index 0, which means it should only show the first data in the array, which is the x value. So I'm going to click outside and it only shows the x-value. Now you can go ahead and write one here, and it will only show the y value. And there you go. That proves that the position of anything on the canvas is stored in a data structure called array. Okay, and that's it for this video. We started this video out by an introduction to a new datatype, which is number. Then we learned about how the position of an object into Canvas is represented using two numbers named x and y. Then we delve into the concept of arrays and we learned how to create an array using the same variable style syntax and how we can access data inside the array using array indices. And one thing again, to remember that index in an array starts with 0 and not one. And then we saw that position is represented using two numbers, x and y. So it can be stored in an array of two numbers. And we just saw that as our final example. In the next video, we will learn something very important, which is this dot notation, which means basically how to target a particular property or how to target a particular layer, how to traverse to it. And when I explain that to you, you will totally understand this piece of code right over here. So I will see you in the next video. And I can't wait to see you soon. 5. Traversal using the Dot Notation: Okay, welcome to the third lesson in this class. And before we proceed with this lesson, I just wanted to do a quick recap of everything we know so far. Okay? We know about how to add expressions to a property, which is by option clicking on Mac or Alt, clicking on Windows, write an expression panels opens up where you can write a couple of expressions in code. We have only so far add an expression to the source text property. I'm aware of that, but we'll add expressions to more and more properties in a similar way. In due course, we know about two datatypes, which is string and number. String datatype is used to store text and number data type again is used to store a number. We also know about a data structure. We also know what a data structure is. So we know about a data structure and that is array. We also know that a position of an element on the screen, right, or on the Canvas can be described by two numbers, x and y. X is the horizontal distance from the left edge of the canvas, and y is the bottom. As you go below the distance from the top edge of the canvas. And position can be shown in expression or code using an array of two numbers. We know all of this so far and that is great. In this video, we will learn about Travers thing and targeting layers and their properties using dot notation, we will learn about the index of layers. And both of these will be very important when you're writing more complex and interconnected expression. So pay close attention to this lesson. The first thing that I want to talk about is dot notation and show you a way of structuring and accessing data in the JavaScript programming language. Now, remember that aftereffects expression, the code you write for after expect expression is based on the JavaScript programming language. And that is why we are peeking into the code to try to make more sense of it. Now, please understand that we won't be using this code anywhere in the expression. But the general idea that I'm going to share is going to remain the same between this code over here in, but if you're going to write in the expression, and again, you don't have to memorize this code or even understand it fully. The code is just to put them mental model in your head about what we're going to do next. Now consider all this code over here, okay? All this code so far as just a collection of data, okay? And this line over here, which is console.log, is simply used to print the result of some code that we put into the brackets here. Okay, Now, if you try reading this code over here, now this so far, just a little bit, you will find some familiar terms in this code, like the project and comms, which is composition. And then we've got comp one over here and we've got comp 2 over here. So if you didn't know already, you can have more than one compositions in a single After Effects project. And they didn't really have to be called competent and AECOM TO YOU CAN give them descriptive names depending on the context, we will create multiple compositions in the same aftereffect project leader in this same lesson, right? Now, inside each of these compositions, he showed this compositions here. This is comp 2 and this is compliant. Now inside each of these compositions, there is layers, okay? Again, something very familiar. And then inside the layers we have transform, okay? And it contains a property, in this case, the position property. All right, So do you see certain similarities between an After Effects project and this whole data over here. It's sort of like the entire project is represented in Coda, right? For and again, just I wanted to go over one more time that we've got comps, we've got layers, we've got transform and position as similarly in After Effects, we have things like, you know, the name of the conf which is F1. Then we've got transform and under transform, we've got position right over here. And, you know, like I said, it looks like the entire After Effects project is represented in this code over here. Okay, Now that you have a sort of a rough idea of what this all code means. Let's come down to the console.log statement. Now, let's say in this code, I want to target the position of this layer, layer 1 insight into how am I going to do that in code, all right, For to target this position. This is something that I'm going to right now. First of all, I'm going to write project, okay, not in caps lock. So Project dot, then I'm going to write columns, then I'm going to write comp 2 dot layers, layer 1 dot transform dot position. Okay? And once I have typed that, oops, I'm sorry about this position and think I'm misspell it position. And once I have typed all of this thing out, you can see that the output of the code is a 100 comma 200, which is same as the value of this position property over here. And then look at the dots here. Do you see Project.com dot com to dot, look at the dots here and the free use of dogs, and the use of dots, and the free use of so many dots is why it is called. This way of writing code is called using the dot notation. And we use the dot notation. In this case, we used it to traverse down this particular data. Finally target the position property. Now if it makes it easier for you to understand, just imagine that writing a dot after this particular word or the name basically means opening a box. So Project.me basically opening the project box, then going inside and finding cams. So here there is comes then I write coms dot, which means I have access to everything inside here. Then I'm going to come to dot, which means I open the toolbox. Then I go into the Layers, bugs, layers dot, then I go into the layer one box. Then we'll go into and transform box and finally open the transform with transform dot and x is the position. So, yeah, So if this analogy makes it easier for you to understand that notation used that NAT traversal in After Effects works in a similar way. Okay, so let's go ahead and have a look at the code that we wrote in the previous lesson and see if it makes sense now. Okay, So it's clear that view, views that dot notation here. So we've got this comp dot layer dot transform dot n dot position. So let's try to read it like English. First of all, this com, which is a keyword, a command that After Effects compiler or the computer understands, but basically means the composition that you are in right now. So comp 1 with dot layer and writing debug layer in the bracket, we are basically accessing this layer over here, whose name is debug layer. And then we go into transform. So as you can see, debug layer Transform, and then we have dot transform that position. So we open up transform box again and we get to the position. Now before we move forward, there is something important that I wanted to talk about. We have come across the concept of index before it with arrays, as in the first element of the array has index 0, the second element has index one, the third element has the index 2, and so on. Now when you have layers and after effects, for example, this is layer one. Alright, I'm trying my best to replicate that aftereffect timeline user interface. So yeah, so in After Effects, all of these layers, layer one, layer two, layer three, they also inherently have an index. The crucial difference here is that in arrays the index start with 0, but in layers the index start with 1, 2, 3. There is no 0 index four layers. So if I go back into After Effects this layer over here, since it is at the top debug layer, this layer has the index of one. If I go ahead and create another layer, let me just create another text layer. So this layer right over here is at the top right now, so it has the index of one, but if I drag it down, this will have an index of two. So the top layer starts with index 1, 2, and if I create another layer below it, it will have index 34 and so on. And I'm telling you this because this particular piece of code here, Lear debug layer, right? This particular piece of code which takes in the name of the layer to target that layer also accepts the index of the layer. Now, since debug layer has the index of one, I can write one over here and it will show, it will still be the same and it show the position of this particular layer, the debug layer 684, 776, as you can see, now, if I change this number to two, which means it will target the layer at index two. And it should show the position of the layer at index two, which again has the position of 1942 1190 and right over here, 9421190. So again, in this particular piece of code, you can target a layer using either the name of the layer or the index of that layer. Now, just like I can use the layer and its different form, one with the name of the layer and there were the index. I can similarly put another piece of code here which doesn't only target like this composition, it can target other compositions. And they've also promised you earlier in this lesson that we will create multiple compositions and, you know, try to traverse through that composition. So this is a single aftereffect project and it already has a composition called comp one. I'm gonna go ahead and click here and create a new composition. And I'm just going to call it calm too. And like I've mentioned before, that depending on the context, you can give more descriptive names to your compositions. And I'll choose a different color for this composition. Let's say red, and I'll click Okay, and now I'm inside column 2 and I'm going to go ahead and create a new text layer here. And I'm going to write the value I am in column 2. Okay? So this is the layer and calm too. Now what I'm going to do is I'm going to do, going to comp one. Okay, I don't need this hello layer anymore, so I'll delete it. I will go into the source text property and I want to target the text of this layer. Okay, So here's how to do that. Again, really use dot notation. Okay? So instead of writing this comp, which will target this composition, what I will do is I will write com, okay, open bracket. And then I can put in the name of the composition that I wanted to target. And After Effects is very helpful at all. All the way shows these auto-fill options so you can navigate using the arrow keys and press Enter to select something. Okay, Now, comp, com tube will target this composition, the second one or not, really the second one, but whose name has come to, then I'm going to type in dot layer, okay? And I'm going to go ahead and select the layer of index one, okay, then I'm going to go into layer one and select the text property. And then I'm going to go inside text and select source text. Okay, so there you go. I'm gonna go ahead and click outside and you can see that it is, it shows a text that is present in the other composition that we created, the CO2. So again, let's go over it one more time. Target comp, comp tube. Okay, so I've targeted this I target layer whose index is one. So again, we know that the first layer has the index of one. Then we go into dot txt, which means dot txt. So open this box, then we've got inside text, source text. So I select this property right over here, and source text stores the actual value that is in a text layer. And I mean, if you didn't know that already, so that's what we have accessed using this particular dot notation little piece of code. And now you know how to traverse and aftereffects using expressions. You know how to get to a certain layer and a property inside that layer. And how do I even get to a different composition in the same project and pick a layer from there and a layer property from they're all using the dot notation syntax. And that is really cool and that is going to be really handy and helpful in the next video where we will be doing some animations, right? And I'm very aware that so far we have not animated anything, but that changes in the next video, like I said, remember we will learn a few new concepts and also create an animation using expressions. And you will see that without expression, it would be very difficult. It would have been really difficult to create the same animation manually using just your hands and keyframes. So yeah, I'll see you in the next video and take care TO then, I guess. 6. value & valueAtTime: All right, Welcome to the fifth chapter, the fifth lesson of this class. After all that we have learned so far about expressions, we have not seen anything cool happened on the screen yet. So in this lesson, I want to demonstrate why expressions can be super useful. And also we will learn about some new things. So let's get started. I'll create, click on new composition. And I'm going to just call it Comp 1 2000. By 2000, I'm going to choose the background color or black. And let's choose three seconds for the animation duration, I'm going to click Okay, and now here we are. Okay, so the first thing that I want to do is grab the rectangle tool from over here, and I'll choose a fill for it. Let's go with something like this, this color, the color doesn't really matter. You know, it could be whatever you want. And then I'm going to go ahead and drag square on the screen and make sure that is the square I'm going to hold Shift to constrain its dimensions. And then I'm going to let go. And you know what, there, there it is. There is our little square. And right now if you're looking at the timeline, you can see this rectangle is selected, but what we really want is this shape to be selected. And you can see that the anchor point is over here. We don't want the anchor point of the shape to be over here. We would like it to be in the center. So I'll click on the pan behind tool. And then I'm gonna go ahead and drag it to the center. And I hold command so that it snaps in the center. And also I just, you know what, I would just want to make it a little bit smaller. So I'll hold Shift and drag it like this. Okay? I'm going to put this square root over here and I'm going to go into the Layers panel. And I'm going to go ahead and rename this layer to liter line leader and will be clear in a bit. Now I'm going to talk about something that could be a little confusing. It was a little confusing to me initially. So just pay close attention. Okay. Now there is a keyword in expressions. When you write expressions, there's a keyword called value, which quite simply means the value of the corresponding property. For example, I've just opened up the Transform drop-down or the nesting or whatever you want to call it, of the leader layer. And I'm going to, I'm going to go ahead into rotation, and I'm going to go ahead and option click on the rotation property so that I can write an expression for it. Now, the keyword that I was talking about is value. So if I write value here and click out, nothing actually happens because all value is, is, it's essentially a reference to the value of the property that you're writing the expression for. Since this value over here references this property, I can write something like value equals 45, and I'll click outside and you see that the rotation now has the value of 45 degrees, because value equals 45 basically means the value of 45 has been assigned to the rotation property. And this writing value equals 45 is simply a longhand method of just writing 45. So if I just write 45, 45 is assigned to the rotation value and it rotates. And if I write value equals 45, it does the exact same thing. I talked about value here because there is something called the value at time that I'm going to talk about later. And when I do that, I wanted to make sure that you understand what value really means. Another keyword that I wanted to talk about right now is time, which simply means the value of time in the timeline. As you can see here, the text in blue represents what time with this. So if I drag this play head around and let's say if I go to 1 second, it means that the values once I guess so that was time. Time means, okay, so let me show you, I'm going to collapse the lead or layer and I'm going to go ahead and type a new debug layer. We often do this when we are dealing with expressions and 12, make sure, you know, the values are okay or not. And since a text layer is getting its property, the text that it's holding from the source text property. I can go ahead and Option click here and simply write time. Or I can write value equals time, it would mean the same thing, right? So if I scrub around, you can see that the time is increasing at a time changes over there. And again, to reiterate on what value is value equals time basically means the value of source text equals time. And if I remove this by default, it is still the same thing. Okay, so now you know what value and time is. And you can combine both value and time. I can, for rotation property again, I can write value equals time. So if I click out, you can see that as the time increases, as I am dragging the playhead, you can see that it's rotating a little bit. Do you see that? That's cool, right? And if I want to make the rotation a little bit more steeper, I can multiply time by, let's say a 100 and I'm using the asterisk symbol, that's the multiply symbol. And programming, I'm using the asterisk symbol to multiply time by a 100. And now if I go ahead and scrub the play head, you can see that it's rotating a lot, right? And remember, right now, I can remove value equals and it would still mean the same thing. I've said this so many times. I just want to make sure that I have hammered the point home and that you understand just writing a value means you assign it to this. I always think, you know, writing value equals actually makes the expression more readable. So it's up personal preference if you want to do that. Okay, let me clear everything. I don't want any expressions at all, and we will, in a second start with our animation. Okay, so here's, here's the setup. We've got a leader layer over there. And if you're following along, make sure you have that and let's get started. The first thing that I'm going to do is duplicate the leader layer. So make sure that it's selected and press Command D on Mac or Control D on Windows to create a different copy. And I'm going to drag this down below the leader layer. So a leader too, but the leader to layer selected, just drag it out so that you can see the difference. I'm going to go ahead and rename this layer to follower. Alright? And then I'm going to select the layer again and change its fill to something like a subtle yellow. And now I'm going to go into the, sorry, and I'm going to go into the transform position property of the follower layer and start writing some expressions. So Option click on position, stopwatch, and let's start writing. We need to get rid of it. Okay, Great. I'll just pull this panel a little bit down to make more space and let's get started. What do you want to do is that make the follower have the same position as a leader layer. So for that, the first thing that I will do is I'll create a new variable co-leader, and target the leader layer in this composition and you know how to do that using the dot notation. So this com dot layer, I can either write layer and index1 here, and it'll still target the leader layer. But for now I want to put in the name of the layers. So this completer, and now we have a reference to the leader layer in this composition that the second thing we want to do is get the leader position so I can create a new variable called leader position. And now I'll simply ride leader dot transform position. And just like that, I now have the position of the leader. And you can see that I'm breaking the entire dot notation into different variables. And this way it makes the expression a lot more readable, something that is a little closer to English. And when it's written leader dot transform position that After Effects, expression engine already looks at leader and says, Oh, there is a liter, which is this layer. So it's still entirely means the same thing. The next thing I'm going to do is simply write value equals liter. This is Shin. And I just taught you about value. Value is simply the value of this property and value equals to their position. As I'll click outside, you see that that follower liter, sorry, the follower layer is zooms the position of the leader layer. It is now stacked behind it. And again, just a reminder that you don't have to write value equals, I can get rid of it and it will still do the same thing. But just again, to make the code a little bit more readable, I like writing value equals. Now with this out of the way, I'll collapse the follower layer. I'll go to the leader layer into transform position and I'll create a new keyframe. I'll just put it the leader layer, just add this corner and I'll create a new keyframe for position. Then I'm going to go ahead TO 1 second and I will move the leader layer to the bottom right corner. And then when I press play, what happens is very expected. The leader layer animates their animates to the final position, and the follower layer just takes behind it all the time. Ideally, for an interesting animation, the follower layer must lag a little, right? It shouldn't be behind in time with respect to the leader layer because this is quite bland. Nothing is really happening. Now let's go ahead to the expression in followers position and make some few small changes. I'll create a new variable. So I'll just click, sorry, I'll press Enter to create a new line and I'll link this value will pay. I'll name this variable leader lagging position. So I'm just going to spell it right. Leader lagging position. And I'll give it the value of leader position that I have, you know, already declared here, dot value at time and inside the brackets I'm just going to write time. And then instead of assigning leader position to the value, I'll assign liter lagging position. Okay, this variable right over here that we just created, I'll click outside and again, I'll scrub through and nothing really happened and we will get through that why nothing happened? But I want you to for now pay close attention to value at time because this is something new. Now, you already know what time is right? Where the time keyword does. And then if I go ahead and subtract a small number from time, from the time that is passed into the value at time, right between these brackets, if I go ahead and subtract a small value from it, Let's see what happens. Let's subtract minus. So subtraction signs minus, and let's choose a small number, say 0.1. And if I click outside, and if I go ahead and play that animation again, you can see that the follower lags behind a little in the animation. Now how did that work? Well, the power of value at time is that it can give you the value of the property you are asking for at any point of time in the timeline, right? So basically what we are saying using this particular line of code and the expression is that give me the value of leader's position, but at a time that is slightly behind the actual time. So time is actual time, right? When we have the actual time, it returns the same position and the same position is assigned to the follower. That is why if you're not seeing any lag, but here when we say negative and 0.1, which means go back in time 0.1 seconds and give me that value. And that value is then assigned to the follower layer, and that is why it follows the leader. Now, right over here, I've just subtracted 0.1, which is a small number that I guess it could have been any number at all. And you know, it depends on the kind of animation, the feel of animation that you are trying to achieve. But I just wanted to introduce a new concept in expressions. And I thought it would be a great point, right? So that we're not only guessing small numbers meant we have some actual math behind that. So this brings us to our, another special keyword that a understands, which is frame duration. Frame duration simply means for how many seconds, right? And remember it is seconds from how many seconds does a frame last? Now to repeat something that you might already know is that an animation is simply, you know, it is different frames, right? Uh, many, many, many different frames. Just blade at very fast speed so that you can see something animating. So when a composition, when a composition in After Effects, it is assigned frame rate. That what it means, it means when I assigned, when I go into this com and I'll look at the frame rate by pressing Command K or control K to bring up the settings. You can see that it is the frame rate is 24 frames per second, which basically means that in 1 second, 24 frames are shown and that is the fried bread off a composition. Now this means, this means again, I'm going to write a little equation here. In 1 second. 24 frames are shown, right? So for how long does one frame last? And that math comes out to be one by 24 seconds. And this is around, I guess your point, 0, 4, 1, 66 something. So let's get back to After Effects and check what's the frame duration for this particular composition. Again, I'm going to go ahead and create a new disk, a debug layer of text layer here. Then I'm going to go ahead and go into Source Text option click and simply write this comp got frame duration. And remember that you cannot just write frame duration because frame duration is a property of a composition. So you have to prefix this comp or calm and in brackets whatever you're targeting. So I'll click outside and you can see the value comes out to be 0.0416666, which is basically one divided by 24. Okay, Great. And now I'll just delete this layer and go to the follower layer. And instead of framing minus 0.1, I'll simply write this comp dot frame duration. And if I click outside, right, now happens, now just to make the expression more readable as extract this, right? So I'll press Command X to cut it down. How Create a New, I'll create a new variable and call it lag time, right? So I'll just call it last time and I'm going to write, just press this dot frame, this conduct frame duration, right? And I can simply just go ahead and subtract like lag time from here. So I just extract this out. That's all I did. And I'm click outside and it will still function the same. Now you know what's cooler, not one, but many followers. Okay, so I'll just go ahead right now, just one follower. I'll just select the follower and create multiple copies of it. And I'll just go back again and press Space to preview. Well, you know, it's still the same. You know, many followers means many followers should have shown, but there's still one follower. Well, that is because each follower is just stacked behind the same follower. I'll tell you why. So I'll press Command Z a couple times and just have one follower here because all of them have the same lag time. And we want it to be a little different for each of the follower that has stacked in the layers panel. And here is the index property comes in very, very handy. So you know that the first layer has index of one, the secondary index of two, and so on and so forth. If I want to increase the lag time for each follower, simply multiply it by the index of this layer and I'll click outside. Okay, and I'm gonna go ahead and create more copies of this. And then when I hit play, you can see that. You can see the follower is just following the leader like so. And it looks a little beard right now, not really very beautiful. So I'm going to go into the position of the Leader layer. I'm going to select both of these, and then I'm going to go ahead and go to keyframe assistant. And let's choose Easy, Ease, okay, so I've added a little bit of easing and now let's look at it and that looks a little bit better, doesn't it? Right? That looks a little bit better. And you know what the best thing that I like to do after doing this as right-click on here, go to Keyframe Velocity and just make these a 100. So now that the acts a little bit, nice little detail. So looking at this, right? So that looks pretty phenomenal designates. And what I can also do is that remember I'm only playing around with the leader layer. I'm not touching any of the followers. There are just being, you know, position animated using the expression so I can change the path of the, of the leader layer like this. And the followers will follow that path, right? Look how cool is that. And you can imagine using this in different scenarios, giving different followers, different sort of colors and everything without expressions doing this animation, you know, such a versatile animation would be really difficult doing this with different keyframes and matter with the positioning and changing the lag time and changing the easing of each of the following food assigned to do so. Now one thing I really wanted to talk about before leaving you with this video is that I'll just get rid of all the followers again and go into the expression right over here. So what I wanted to talk about is that this expression has variables and it might look a little different from other expressions that you have, might have found on the Internet or, you know, copied to your library and whatnot. The reason is that the way I've written the expression, It's very verbose. I can change this expression to look a lot more complicated than this. So let, let me, let me go ahead and try and doing that right just in front of you. I'm going to go ahead. So I'm going to just press Command C to keep a copy of this. So all I can do for this particular, you know, to make the same thing happen and knowledge. Write such a verbose expression is I can do something like this comp. Nothing. Thanks. Okay. Not for injuries. You can do that. So I can go ahead and get rid of all of this. And I'll click outside and there will be no errors and the animation would still work like it works. I'll create more copies of followers. Like so. And if I press Play, you can see the same animation still works. So my overall goal here is that, if you will, because most of the variables that they will, sorry the most are the expressions that you'll find on the Internet, but they will not have such verbose a version of the expression written like this. They'll simply have a single line and, you know, veered variable names like a single letter, like L or whatever. So I just wanted you to know that you can do that. But if you're writing expressions, it always makes more sense to make the code more readable, not just for others to read, but also for you when you revisit it in the future. Great, I hope you learned a lot in this video. I think we are touching the 20 minutes Mark, and I don't wanna do that. So I'll end this video here. And in the next video, we will put everything that we have learned together in this class so far and create a template text-based animation. It'll be really cool, and I'll see you then. 7. Putting it all together - 1: All right, welcome to the sixth lesson of this class. And we made it so far. We've made it together so far. That is really great. And in this chapter we're just going to use all that we have learned so far to create something really neat, something that's practical. And you can share it online or you can post it as a project here, right? And along the way, as we will do that, I'll also teach you one or two new after-effects techniques, but nothing major when it comes to expressions. Alright, so let's get started with this lesson. I'm inside a new After Effects project, so just, you know, new, new project. This entire window will show up. And inside this project, I want to make two compositions, okay? The first composition, I'm going to make my clicking here and I'm going to give it the name of template TMP LIATE, and I'll give it a dimension of again 2000 by 2000 pixels. Okay, great. I'm going to give it a frame rate of 24 frames per second, and I'm going to give it a duration of three or five seconds, doesn't matter. 3 is fine and a background color of black. And I'm going to click, Okay, I'm going to create another composition. So I can do that by clicking here. And I will give this composition the name of animation, everything. All the settings will remain same as a template 1, so it's auto filled. The only difference is that I want this column to be just a second long. So I'm going to click Okay, and now you can see that I have two compositions, animation and a template. Now inside, and this is important that you are inside the template com, just make sure that this tab is selected like this. It says template, I'm going to create a new text layer. So I just clicked on the text tool, click on the canvas, and then I'm just going to type in text or the content of it doesn't matter that much. The next thing that I'm going to do, which is important, is slug this layer here and name it main layers. So I'm going to select the layer, press Enter and call it main layer. I'm going to press Enter. And in a bed it will be clear why this layer has a name of main layer. And it's, it's position could be anywhere you want. Okay, it doesn't matter. Now I'm going to go into the Animation column, right? If it's not open in a tab like this, just double-click here to open them and tab, and I want to create another text layer here. So I'll click on the Text tool, click over here, and I can fill it with any text I want. The content doesn't really matter, but I'm just going to write captured text here, okay? And I'm going to click out, all right? And there are two things that we want to make sure here with this particular layer. The first thing is that the anchor point is in the bottom left corner. And if you don't know how to move anchor point of it somewhere else, just grab it with this tool. I've mentioned this before, but rabid this tool, hold Command and snap it. Okay, I'm not going to tell it again. So make sure that the anchor point is in the bottom left. And the other thing that I want to do that we want to make sure is that it's stuck to the top left coordinate, right. So for that I'm going to go into the position property. So here's a little shortcut for you. If you're select the layer and press P on your keyboard, you can directly see the position property. And because I want it to be stuck to the left edge, I want the x distance to be 0. And the y distance will have to eyeball it should be as just drag it over here, but should be the height of this text layer. So I'm just eyeballing it and nudging it using my keyboard, arrow keys. So yeah, let's leave it there. And just like that, we have another text layer inside the animation comp. The next goal is to get whatever text data that is in this layer, the main layer in the template come to this particular text layer that we just created. And you already know how to do that. I mean, if you can figure it out in your head and write the expression for it, go ahead and do that. But here's what I'm going to do. Since the text property of any text layer is handled by the source text property, the textContent of any layer. I'm gonna go ahead and option click and start typing. So the first thing that I wanna do is get to the template columns. So I'm going to write com template, then I can write layer and the name of the layer, which is main layer and see how beautifully after-effects suggests the layer names. And then we want to get the text property. And then inside that I want to go into source text and I can click out again and you can see that the text is captured. So again, we went into the comp template, this template main layer, that event into the text and captured that source text property. If I change the text value here, do something like hello world. You see that this value will be reflected over here in the captured texts layer. Now, like I said before, you can either write the expressions in this search compact way or you can split it into some, something like this. So I'll create a new variable called me text layer, which will grab the, the, the main text layer that is present in the template com. So this is how you grabbed layer. Then you can create a new variable which stores the main text data, which will again be men, main texts layer dot, dot source text. And then Alice will assign this value. To the text, the source text property of this particular layer. So I can do that. Now this entire code just means the same thing as the previous single liner that rewrote. It's the same exact expression, just a little more readable. But you made the choice here if turning one-line expression into something like this is worth it for you or not. So I'm going to leave the verbose, whereas in here, and I'm going to click out, and now we have the link to the text here. So any changes that I made into this text will be reflected in this text over here. Great. Now I wanted to create duplicates of this text wrangler, this one right over here and arrange them vertically so I can press Command D and I will drag this down, and I'll drag this here. Then I'll press Command D again and drag this here. No, I'm just kidding. Who wants to do all the manual work? Maybe you can just write expressions for this, right? So hold it. I'll delete the copied ones now before we write any expression to arrange them vertically properly, I wanted to explain how all the calculations will be done and how everything is going to work out. So follow me. But hold on, hold on, hold on, hold on. Just a little bit of setup. Before we jump into that explanation, I will go into the position property of this facts so I can collapse this. There's the position property and I will right-click and click on separate dimension. This will give two different properties for position x and y. So x position and y position. Remember that for this trend in its whole is an array of two numbers, but each of these is just one number datatype, so it's easier to access one of them were in just work with it because we will be only animating the y position for this animation. Okay, Now I'll just go ahead and change the value from Hello World to just text. Okay? Just because it's lightweight and helloworld is a little too much. It isn't the reason I did that, but I just want to have text here. Okay, So once I have this here, what I'm going to do is select this layer and press Command D and create a copy of drag this copy down the captured text2. And with the capture texture selected, I'm just going to just drag it over here for now, okay? And now we can look at how everything is going to work. So again, we have these two layers over here, captured text and captured tanks. To. The first thing is that the kind of list that we are trying to make of texts, the x value of each of these anchor points right at the x value. So anchor point or the whole object has, is represented by an x and a y value. All of these texts have the same x value, only the y or the vertical value is changing, right? So what we can do is I can go back into After Effects and I can go ahead and connect the x values of these two layers. To do that, I'll go into the capture text2 and you know what, while VR at it, what I'm going to do is I'm going to name this layer leader, okay? And you know where I'm going with this, and I'm going to name this layer follower, okay, and now I'm going to go ahead and connect the x value of follower to the x value of leader. And to do that, I'll go into the Transform, going to exposition option. Click and just write this com, okay, this comp. And I don't need to put brackets dot layer and I'll write liter ok dot transform, ok dot exposition. And something I'd like to mention is the error or the thing that I always did. And it ran into error is because I didn't write transform, I would just go ahead and write dot x position and, you know, forget about the transform and things won't work. So don't forget about the transform because the position is nested under transport. And now if I click out the x-values connected, so if I move it like this, it moves same in the horizontal direction. And that is really cool. And again, another thing that I'd like to mention here is that writing this expression over here is equivalent to doing this. I can go ahead and delete this. And then I can go ahead and select the exposition, take the pick whip from here and connect it with the explanation of this. And then again, this exact same expression that it writes. But I didn't tell you that till now. So now you know how peak mips were too great. And the cool thing about all of this is that if I create multiple copies of followers, right? For example, this is a follower, this is a, let me just drag them out so they're all overlapping now, but I will just drag them out. And the cool thing is that since we have connected the followers position, the x position with the leader, and then we made copies of the followers. They will all have the same x position, right? And they'll follow. So that is something that I guess he already knew, but I just wanted to show you that with this video, we are touching the 10 minute mark. And I don't want to extend this. We have this far good setup. And in the next video, we will see how we are doing the math to calculate the x position, sorry, the y positions of the rest of the followers. And then we'll be animating them and adding certain cool effects. So, yeah, I hope that you are following along and I hope you have this setup so far, this particular animation, and I'll see you in the next video. 8. Putting it all together - 2: Okay, Welcome to this video. Wherever we are continuing the animation project that we started in the last video. So we're trying to make a list of text like this that we can animate later. And we were trying to not do that, to not make a list like this manually, but around they're using expressions. And so far we have a leader and a follower. And the followers x position is connected to the leaders. Cool. And like I have explained, what matters is the y position of the followers. That's something that needs to be calculated because the x position just requires a simple connection. But the y position needs to be calculated. So let's focus on the y position of the follower layers here. So right now in the Canvas we have these two layers, a leader and a follower. And of course we are going to have more of the followers after this. Now the y-value of the follower layer is of course calculated using the y-value of the layer above, right? Like this, the y-value of the follower layer will be the y-value of the layer above it, which right now is just the leader layer, okay? The y-value of the leader above it, plus this spacing, this spacing between them, plus the height of the layer. So I can write it as an equation as y value of this particular layer is equal to y-value of the layer above. So y value of the layer above, I think my handwriting has improved a little bit. Plus this spacing, let's just call it spacing. This is the difference between these two, you know, a block of text, sorry, I blog, a blog of certain height. The height of this layer was the height of the text layer. Okay, my handwriting is back to being bad again. So this is the equation. And if it wasn't clear, the spacing basically means the little empty space between when we make a list like this. So I'll just make another copy. So a sound to press Command D and make a copy. I'll drag this. So when you make a list this spacing that should be consistent then be space between each subsequent texts is what I'm calling spacing. So I'll delete that and go back to our initial position. Now, there's one important thing that we need to understand with respect to the calculation. Now, consider this sample list off a leader and like 1, 2, 3, 4, 5 followers. Okay, and let's look at, let's say follower and number four in the anchor point or follower number four. And then one important thing to notice is that in this equation that we made are not directly relying and emphasis on directly write directly relying on the y position of the leader to calculate the y position of a certain follower. And you're only relying on, for example, for fall we're four on the layer above. So for it, it'll be follower three, right? We're, we're taken the y value of the layer above bless the spacing plus the height of this particular layer to calculate the value of y. All right? And this in turn, by a chain is linked to the leader, the y-value of the leader, but not directly. All right, now I hope that you've understood all that we've done so far. But still if there is some confusion, it will be clear as we start writing some expressions. So let's get to that. Now we want to write expression that target the y position of the follower layer. And remember that I've already connected the source text to the text here in case you forgot, It's been a long time since I've been watching this video or you took a long break. And then our continuing and will also split the position into x and y position, right? So we wanted to write expressions for the y position. So I option click. The first thing that I'm going to do is create a new variable and call it layer above. Okay, that's just a name that I give. You gave to this particular value variable. And I'm going to assign it to this com dot layer. And again, if I wanted to target the layer above, this layer is going to be the index of the list, this layer minus1. Okay, That makes sense. Great. The number 2 thing that I wanted to do is get the y position of the layer above. So pay close attention here because we have not written exactly this thing before. So I'm going to write let layer above y position. Okay? So I am using very verbose and very explanatory variable names here. Generally a good idea, and this variable will be assigned to layer above, ok, dot transform. Now instead of writing position, I'm going to write y position, right? This is what aftereffects suggest. And now we have the y position, then I'm going to go ahead and get the height of this particular layer. All right, Remember, we need, we need the y position was this spacing plus the height. So I'm going to write let layer height is equal to, now all the layers, all the texts are exactly the same. So you can either target this particular layer and by typing in this com dot layer index. Or we can also use just use layer above range. So because all the layers that are the same will hold the same text, they will also have the same height. Now I run out of breath there. So pay close attention to, I'm going to show you something new. So I spent to beat layer above source, rect at time, all right, dot height. And this is how you get a height of something on a canvas using expressions. Source rect at time is something that will do for you. Very good to remember because very often it happens that you have to know the dimension of an object. You can do them using source rect at time, writing this dot height, or you can write dotted width to get the width of the particular object, but we need a height here, right? And now I'm going to go ahead and create a new layer and call it spacing. So let's spacing and I'm good. I'm just okay. Now, spacing, line spacing and I'm going to give it the value of 50, okay, Just a random number. You can get a hundred, five hundred, whatever. It's definitely just the spacing between these tags. And I've given it to be the value of 50. And now it's time to use the equation that we wrote. Remember, the value that we're going to assign to y position will simply be layer above Y position plus spacing plus layer height. All right, I'm going to click and I'm going to click out and you see that it adjusts itself. And now look it is if I create more copies of the follower layer, here's what happens. So if I create more copies by pressing Command D, They will be automatically positioned properly, which is grade. Just imagine doing this manually, so much hard work, but now I can create any number of copies and the will be positioned properly. And what else I can do is if I wanted to update the text as since all the texts in the animation is linked to this one over here, I can write, hey, I am going to review this class, right? And then all the text over here will be updated. Or I'm sorry, I'm just going to name it. I am going to definitely give this class a five star. If that's the reading system when it goes here, is it stars or is it, I don't remember, but just review the class and give it a good rating. It'll really mean a lot to me every time you read your reviews that you guys leave on my class have that just feels so good. So you can see that everything is linked and how beautifully this, everything just works together. And this is where expressions can be so useful. We didn't have to measure the position and create duplicates and drag around. And if later we wanted to change the position, we won't have to adjust each of these layers individually. I can just move this around and everything moves around with it. And if I wanted to change the font size, I can select everything. I can go into my character panels so I can increase the font size and the spacing between them will still be 50. And that is great. Now I don't want this big font size, so I'm going to press Command Z. Now, what if I wanted to change the spacing between them, like it's 50 right now, what if I wanted to change this spacing? What I'll have to do is, okay, what I'll have to do is to delete all the layers or the follower layers except one, and then go into the expression. And let's say I want to change to a 100 and I can change it to a 100. Alright, so you can see it's shifted down and then I can go ahead and create multiple copies of it and the spacing will be 100. But that is just relax. We don't wanna do that again and again. You know, to write this spacing, a delete everything and update the spacing, and then again, create copies. We don't wanna do that. So here's a technique. You don't have to, you won't have to do that entire procedure to change the spacing. Let's go back to our template layer and I'll swipe the layer over here, which is main layer. Then I'm going to go into the effects and presets panel. Again, it's under window if it's not visible effects and presets. And I'm going to search for slider control. And I'm going to slide this, sorry, I'm going to drag this over the main layer, just like that. And this will add a little bit this little slider control under Effects Controls. So I can go ahead and rename this. I'll rename this to spacing. And now you already know what we're up to. We want the spacing between the tags with DAPI will create to change with the value of the slider. Okay, but how do we connect the slider to the spacing variable that is here. Sometimes we need a little help writing certain expressions like for example this one. And to do that, what we have to do is something like this, okay, so I'm going to select any random value that I can write an expression for, and that has a big whip behind it. So for example, let's select Opacity, right? So I'm just going to go ahead and drag this, pick whip and drag it over the slider. And like I showed you at an instance before, that, how groups work is they just connect the property by writing an expression. So here you can see the expression is perfect spacing sliders. This is something that we need to connect to this particular slider. Okay, so I'm gonna go ahead and Command X, cut it out, and just leave everything as it is. I'm going to go into the Animation com, but instead of writing spacing, I'm going to press, I'm just going to paste the value or the expression that I copied and I'm going to click outside. So of course, there is a problem with this particular line of code. Can you see it? I'm just gonna click outside and we're going to run into an error. And the error says that if I act is missing or does not exist, this, this error exists or is showing up because just affect won't work. Remember that the effect is applied on the main layer, which is in the template comp. You'll have to write over here using dot notation and make the proper connection. So it will be comp template, right? Dot layer and the name of the layer is main layer. And I'm just pressing Enter cover aftereffects suggesting the proper name. That's why I don't have to write the entire thing. And then I'm going to write dot. And if I click outside, you can see that it is now connected. And how do we make sure that it's connected? I'm going to go ahead and create multiple copies this, okay? And then I'm going to go into the template comp. And if I increase this slider, you will see that the, it adjusts itself. But you know what's better to sweet see it in real time. So what I can do is I can go to the projects panel and drag an instance of the animation comp over here. Okay? Now if I go ahead and select the main layer and go into affection controls and adjust the slider. You can see that I can adjust the spacing between the texts dynamically. And this is sort of like rigging and animation right now you can do whatever you want to do, and everything will just flow around and follow properly without you having to animate multiple things individually on their own. So I'm going to really just don't need the animation layer here. So I'm gonna go ahead and delete it. So this is the main layer inside template. This is the animation. And now I can go ahead and start animating everything that is inside this particular comp. The first thing that I'm going to do is actually change this text from over here because it's quite stupid. So I'm going to go into the template comp, go to main layer and rename this to just a bunch of hello, hello, hello. You can type whatever you want. I'm just signed in and I'm going to hit Okay. I'm going to click outside and the text should have been updated here. So the error was because your caps lock, if your Caps Lock is on an After Effects will show you, hey, you cannot refresh if you're a catalog codon, so I forget that sort of error, just Turner caps lock off. Also, note that only connecting the text data of every text layer here to this particular main layer. And we are not connecting the font style, for example, the type phase of this using the font science, etc. So all of those can be adjusted here independently. And by the way, I'm using the typeface, huge Gothic for all of these texts here. It's probably free. I'm not sure, but you can use any typeface. Feel like really, the next thing that I'm going to do is select everything and increase the font size enough so that had fits the canvas width properly. So yeah, that looks nice. And the next thing that I'm going to do is create enough copies of followers size that it overflows a level. So Command D, command D, and you know, there were like a couple of more followers here. Okay, and it'll be clear in a second why. And now we can just animate the leader layer and everything else will follow you. So one important thing here, just, you know, just a little workflow technique is that for all the followers, look at this particular hidden, this icon looks like a guy picking behind a wall. So have I have all of these turned off so we can select and then unions Calais can toggle. So for all the followers, have it hidden so that when you click outside and click over here, I can only see the leader layer. This is for if you want to focus exclusively on one layer, you do that. And right now, I just want to exclusively focused on the leader layer so that I can animate this whole, entire com to look like it's an infinite texts crawl. Okay, so here's how we're going to do that. So I'm going to select leader press P, and we're not going to animate the exposition but the y position. So with your, with your playhead at the very beginning of the timeline, click and add a little key frame. Then it will go to the end and add another keyframe. And let's see if I can drag it to the Andy. Yeah, there you go. At 1 second mark because this comp, if remember, is a second long, okay, Now here, what we just want to do now is that we want the leader to move ahead and move up such that it's almost the same exact thing. So here's what I mean. Okay, so I can't drag my playhead to the extreme end, but you know what, I'll just move this keyframe here and then animate and then move the keyframe to the end later. So right now I'm just gonna go ahead, hold Shift and use my up arrow. Didn't nudge everything a little and we just want it to be the same as it was before. So it looks like an infinite loop. So I'm going to hit space and it should look like an infinite loop. Yeah, there it is. We just moved it ahead so that this follower took the position of the leader. And that is why, you know, it just looks like an infinite scroll if you let it let it play like this. So yeah, that's quite cool, isn't it? And if your animation is not looping in the preview, all you want to make sure is that you have window preview on. And this particular icon. It's not like half-open but fully closed. And then it will play like so. Okay, Great. And I've also drag this key frame to the very end again after adjusting the position. So that is nice. And now what I want to do is I'm going to create a new composition. Let's call it Test 1 because we can just create different versions of the animation now. And I'm going to choose a sort of a bright blue for the background. So I'll hit Okay, and I'll hit Okay again, and this particular new comp is added and I'll drag an instance of the animation comp here like that. And if I hit play, it will again look the same. That's good. And now I can add effects over this instance of animation com. So I'll go to effects and presets for now. I'll just drag it up and find out polar coordinates. Okay, So I'm just gonna go ahead and drag it over this particular comp over here. Then I'm going to change it from red to polar and set it to 100. And look at this, look at this, right? And it's sort of looks like everything is being sucked in. But if you want to make it look like a loudspeaker, what I can do is right-click on this comp, go to time and go to time reverse layer. And if I hit play, you can see it will look like everything is just emanating out of there. So this is a nice little effect that you can have. And then we can also do something like, let's press R and go to the rotation property option. Click on rotation and let's type in time and FAD and look, look, look like how that looks like. So this is again, you say that again, some cool that you can have, right? And you know, just to make it look a little better, I'm going to click on Add animation, this compress asked to give the scale on and just decrease the scale a little. And I'm just going to press Space to preview and yeah, look at that. And it looks cool, doesn't it? And the best part about this best part about all of these that are really like imagine you're making something like this for a client or for your project. And you know, a change happens that you have to accommodate, for example, the change of text. If someone says, Oh no, that the all Jeanette hellos should be lowercase. So yeah, so I have to only make changes on one place and that change will be propagated to this particular, the final animation, whatever you make through the animation comp. And that was great. I'm just going to press Command Z a couple of times to go back to the original animation. Okay, so the point was to tell you that expressions and the normal ways of working like keyframing, etc. They both work great together in companionship, it's not that you have to use expressions exclusively or the normal way of animating exclusively. I think that's very obvious and it doesn't even require me telling you. But now you know that with her regular way of animating where you add keyframes, et cetera. There's also expressions which can automate some grunt work like changing text at five different places or, you know, the adjusting, spacing and all of that. So those work great together. And that was all for this video, I think are very much near the 20 minute mark. I apologize if you don't like longer videos, but I have to show this animation and I had to make a point. So anyway, I'll see you in the next video where we will talk more about expressions and conclude this class. Hopefully. 9. Conclusion & What's next?: Okay, So we're in the last lesson of this class and at this point there are some things that I'm hoping for. I'm hoping that expressions are no longer just hieroglyphics to you. I'm hoping that expressions now is not something that you would find on the Internet and just wanted to copy it, paste it after required place and be done with it. I'm hoping that if you look at an expression now you should be able to pick out parts of a lag variables and the dot notation to traverse to a certain layer are to a property of a certain layers. So you can pick those parts out. And if required, you can also make changes to that expression to make it behave it and the way that you want as opposed to I use it for just what it's been written for. I hope that taking this class has been a sort of like a gentle push on a door, on the door that opens up to the wonderful world of expressions. And now that you have pushed the door a little, you can peek inside into the world of expressions and also not be afraid to actually enter it further in this class, I will tell you a few more things. Bound expressions share resources that I'm actually using to learn more about expressions. And then in the end, but you Pharrell. So without much ado, let's get back to After Effects. Now I'm inside After Effects with one yellow square and the canvas. Now if I go into squares, transform and position, and I option click on position as if I'm about to write and expression. You'll see this little Play button over here inside. This is the menu filled with expression helpers. Let's have a look. There's very advanced stuff at the top or even on like generally spread throughout this minute there are some very advanced stuff. Then if you later decide to go deeper in, you can use this menu to add them automatically. Let's see how we can use this menu. And let's look at one of the built-in cool expressions that you can add from here. If you go down here into property and you'll see a couple of familiar things like value, value at time, things that you already know, but you'll also find something called wiggle. And if you click on vagal, you'll see that it's automatically added to the expression panel. And here is a bunch of more code to indicate what needs to be filled in. We don't need to worry about these last three from Octavius to time. We don't need to worry about the so let me select them and press backspace to get rid of it. And let's go ahead and fill ten where freak or frequency is written and 50 where amplitude is written. I'll explain in a bit what these numbers mean. So I'll click outside. And if I click, sorry, not click butt press space, you will see that the square goes absolutely bizarre in vagal and in other functions like wiggle, you have to provide it with certain parameters. These things that go inside the bracket, these ones here, these are called parameters for wriggle, the parameters are frequency, so the first number is frequency and amplitude. Frequency is how many times per second the property's value should increase or decrease. And amplitude means to what extent. So if I set frequency or FREQ or Frank, if you'll recall it to something low, like to write, you will see that the square will move less often, so it moves less often. And if I increase the amplitude, I mean to what extent the square is allowed to move to sunlight, 300, you'll see that it'll move farther away from its own position, right? Do you see that? You can tweak it according to whatever works for you. Let's go with something like 80 and 300. Let's see how that looks completely Masaryk, 80s or frequency. So it's happening more times per second, but yeah, the rest from here is up to you to explore. And now let me introduce you to a few resources that I'm using to delve deeper into expression myself and how you can use them to. So let's go ahead and check out the resources. And of course I'll leave the links to all these resources in this class has resources. So yeah, the first one is motion script.com. It's an old and gold resource that's been around for so long. And I think many expressions veterans have actually used the desk particular site to learn. And if you go into this particular link called Mastering expressions, you'll be able to learn much, much more exactly from one-to-one to all of these extra things like if else conditionals, I already just something that I already told you, then you can worry about sine and cosine and everything else. So just click on any of these or just follow along from the top. These are very short articles and you can go through them in a very less amount of time and also learn a lot, right? So I'll click out of this resource, but remember the next thing. If you wanted to learn an expression, it should be if else conditionals, these, these will be pretty cool. Okay, Let's go to this particular Google Doc. I copied this link to this Google doc from Ben Marriott's video, which is also mentioned here. And he, in here, you'll find some nifty After Effects expressions, right? That you can also watch from this particular video that's here. Okay, now I open this dot just to show you how expressions are usually written, right? So let's look at this expressions which has maintained scale when parents had. So I'll just copy the code and paste it somewhere. That little make it more readable so I'll paste it here. Okay, Now first of all, you'll see that this particular line, this is a variable that creates an empty array, right? You should be able to notice that now two things or several important things is that there is no let in front of the variable name, which is S right now, right? So the way JavaScript works is that in certain conditions you can omit Let and JavaScript will still create a variable for you. So omitting let here works because of the conditions that is met inside the expressions panel. But I'll suggest it's always a good idea to prefix it with the lead. And another important thing to look at here is that the variable named written here, as I have warned you before in this class, is simply as a non descriptive. And remember the variable names that we use, layer above, layer above position and all the verbose code that we wrote. So you know, having just a variable name that is S or P, S. Great, Not great. Try to write the entire thing. So the thing is that even now if you come across an expression like this, we'll be able to understand, right? And then there is S and P, S, and this S is then assigned to the value, right? I'll have to read where this essentially goes. This, this expression definitely doesn't go here. That is when there is an error. So I'll delete and go back. You can watch the video and learn more about this here. So the thing to take away from this resource is the omission of lead that is allowed and not, don't create variable names that are S and P as just be a more descriptive, be more descriptive, not all more. What has happened to my grammar, and the other important thing that I want to talk about is the semi-colon. So in JavaScript, also you can omit the semicolon. The semicolon has an optional. So don't worry about it. Okay? And from here too, like in the last resource I told you to learn if else conditionals moving forward, the next thing that you should learn from moving forward from here is four and loops. So if you're noting it down somewhere, noted down. And the last resource that I want to add that I'll share with you. I don't really remember where I got this from. Definitely I have not written this. Maybe I got it from Reddit or some YouTube video, I'm not sure. So credit to whoever created this. So you can go through all of this. There are a bunch of shortcuts and there are a bunch of expressions and what they do so you can go through them and learn more. And of course, like I said before, you will find the link to all of its resources in the resources section of this class. Let me know how you like this class. If you want, you can leave a review to, or if you are stuck somewhere, you can pop into the discussions and I'll be sure to help you out there. Or if you want to talk about something general, just hit me up on Twitter. Here's the address. It should be on the screen. And if you want me to make a part two of this class with more advanced expressions, let me know as well. And I'll see you soon in a different class. Goodbye.