Transcripts
1. Trailer: Hey, I'm Jake Bartlett. I'm a motion designer based in Denver, Colorado and I've been using After Effects since 2006. This class is advanced After Effects, build a motion graphics templates. In this class, I'm going to teach you how to make a motion graphics template and these templates or Mogrt, as Adobe likes to call them, are designed inside of after effects like any other animation but then they can be customized insider Premier. You can give the user specific controls on how to modify and customize the template without needing to go back to after-effects or to update but even if you never need to go into Premier, you can still take advantage of the essential graphics panel and how you create motion graphics templates to speed up your motion design workflow directly in After Effects. To take advantage of these tools, we're going to need to know a little bit of code and I know that might put a bad taste in your mouth. If you just want to make things move, expressions, the coding language in After Effects might really turn you off but trust me, once you understand them and you start to see how you can use them in your workflow you're never going to turn back. In this class, I'm going to walk you through the very basics of expressions, as well as walk you through every single expression that we use step-by-step so that by the end of this class, you're going to have complete confidence using them in your own motion design. For the class project, we'll be building a lowers third templates that can be overlaid on top of video just like this one.This class is for anyone wanting to get into advanced After Effects workflows, whether you actually need to make templates for teams of people to use, or you are trying to sell templates online or maybe you just want to take advantage of expressions in your own personal work flow. Regardless, this class is for you. Get ready to start typing out some code, and I'll see you in class. [MUSIC]
2. Expressions Basics: Expressions are essential for making motion graphics templates because it's the coding language that After Effects uses, that actually allows your templates to be customized. You're going to need to have a basic grasp on how they work, and we're even going to be using a couple of expressions that are pretty advanced. But don't worry, even if you've never used expressions before, I'm going to walk you through every step of the process so that by the end of this class, you'll feel totally comfortable implementing them into your own templates. If you're completely new to expressions, this video is exactly for you because I'm going to walk you through the basics of expressions and how they function inside of After Effects. First of all, what is an expression? We'll expressions is the code language that After Effects uses to be able to do complex things. That code can be written on basically any keyframeble property, and one really easy way to think about expressions is being able to do anything that keyframes can do. If you can control something by hand using keyframes, you can write an expression to do the same thing. The benefit of expressions is that it can make really complex things executed automatically. Now, expressions are actually based on the JavaScript code language. You might have heard of that before, it's used a lot online, but the expressions code itself is not the full JavaScript libraries. So you don't have access to the entire code library that is JavaScript. However, recently Adobe did switch over to fully supporting JavaScript inside of After Effects. If I go down here into my project settings and over to the expressions tab, you see that my expressions engine is set to JavaScript and that should be the default for you if you're using the most recent version of After Effects. If I click on this, I can switch to Legacy ExtendsScript, an ExtendScript is Adobe's term for the expressions library. But using the entire JavaScript library just opens up a lot more possibilities, we're really not going to get that deep into it in this class, but I'd suggest that you leave this set to JavaScript. So that's what expressions code is, but what exactly can we do with it? Well, there's a lot that you can do with it, way more than we're going to be able to cover in one class, but here's a few examples. One way to think about an expression is like a parent from one layer to another. If I were to make a solid layer that's 100 pixels by 100 pixels, I can parent this expressions text to that solid, and it will adopt the transform controls of this layer. So if I rotate it, it's going to follow that, if I scale it up or down, move it around, the text layer is going to move with it. One way to use an expression is to basically parent or link one property to another. If I take this parenting relationship off and I opened up the rotation by pressing R on the keyboard for each of these layers, you'll notice there's another pick whip right here, and this is called the property pick whip. What this allows me to do is basically parent one property to another. If I were to grab this property pick whip for the rotation value of the text layer and bring it to the rotation of the white solid layer, now, these numbers are red and that's indicating there is an expression applied to this property, and if I rotate the white solid, the rotation of the text is adopting the same value. It's not parented to that layer, I can still move it around, scale it up or down and that's not going to affect anything, but the rotation value is always going to match the white solids rotation value. Now, watch what happens if I switch to my rotation tool and try to modify the rotation of this layer. I can't, it's locked and that's because the expression is overriding my rotation control. So I can change the number down here, but as soon as I let go, it goes back to the same value that the expression is giving it. That's really important to understand. The expression is going to override whatever value you put in here, unless you account for that value within your expression. Another thing you'll notice that this adds is a little drop-down arrow. If I click on that, we can see expression on the rotation property, right over here we have a line of code, this is our expression. If I give myself a little more room and click into this, we can see there's little editor for the expressions is actually really useful because it gives us color-coding for this JavaScript language, which can be very helpful for identifying different parts of your code. Now, I didn't have to write any of this code, all I did was use the parent pick whip to select the rotation property and it automatically changed it for me. If you're nervous about expressions, this should make you allow more comfortable, because you don't need to know how to write all of this out, you just need to be able to use his property pink whip to grab something and After Effects fills it in for you. Now, if you notice right over here we have some controls, there's another pick whip and this one is called the expression pick whip. Now, this was not visible before we use the property pick whip. So let me just get rid of all of this code real quick and show you those controls for the expression go away. But if I undo and bring that back, this is going to do the exact same thing as the property pick whip. If I were to grab this click and drag and go to the rotation, it's going to fill in that exact same code. It's just that was not visible before I add the expression. When Adobe introduced this property pick whip, the expression pick whip had already existed, so the only way to get access to that would be to add an expression manually, which you can do by pressing Alt on PC or option on a Mac, and click on the stopwatch that adds an expression, and then we see those controls. But Adobe made it a little bit easier on us, now, that we have this property pick whip, so all I have to do to start my expression is grab something and it automatically fills in that text for me. We have this rotation of this text layer linked to the rotation of the white solid layer, but what if I wanted to link it to a different property? Well, I actually can do that. I'm going to press shift T with that white solid selected to bring up the opacity, and what happens if instead of linking this to the rotation, I link that to the opacity. I'll let go and my expressions text rotated to this weird angle, but if you'll notice it's 100 degrees and the opacity is 100 percent. If I turn this opacity value down and look at that, the expressions text is rotating. Even though these are two completely different properties, the expression code is able to translate the value of this opacity to degrees on the rotation, and it's a one-to-one translation. So whatever percentage this opacity value is going to be plugged in to this number value which is actually measured in degrees. This isn't necessarily a very helpful expression, but it's just illustrating the point that you can link any number to another number. But regardless of how you're using expressions, the end result is always the same. It's going to generate a value to plug in or output to the value that you've applied the expression to. These can be simple links between properties, they can be calculations with complex equations, they can be based off of multiple layers and multiple properties, and they can even have conditions so that if check boxes are checked or not checked, different values will be calculated and output to this value. It seems really complex and it is. It's a really big topic and expressions can do so much. Possibilities are pretty much endless, but there are only a handful of expressions that you really need to understand to start taking advantage of using them in your own work, and even fewer for making motion graphics templates, like the one that we'll be doing in this class. But let's look at another way that we can use expressions. Instead of just referencing another property, we can actually use expressions to generate values that aren't based on anything else in the comp. These are through what are called methods and that's just a JavaScript term for a piece of the language that allows you to generate something. For instance, we could generate a random number value for the rotation for every single frame of our comp. To do that, I'm just going to edit this expression and erase it, and I'm going to start typing the random method which looks like this. I just type out random and you see that as I start typing, After Effects gives me this autocomplete window, this is the expressions library and it's giving me what it thinks I'm trying to type. There are other options in here that have a random in the word, but if I double-click on it, it will autocomplete for me. That text is in blue, letting me know that as a method, it's not referencing another part of the layer or the comp or a property, and then it gives me these parentheses. It automatically gives me opening and closing parenthesis. When you see these parentheses, that means that we can add more to this method to generate a specific number. Now, again, I don't want to overwhelm you, I'm not going to get deep into how this random method works, but if I just apply the expression, I don't actually have to fill any numbers in between those parentheses, you see that my value is now 0.8. If I just play this back by hitting the space bar, look at that, the text is vibrating. Because on every single frame of my comp, After Effects is now generating a random number. The reason why it's rotating so little is because by default it's generating a value between zero and one, so that's why I have 0.1 on this frame, 0.9 or there we have a whole value of one. It's never going to go above one or below zero. But if I went back into this expression in between those parentheses, I could put in any number. Let's say 20 and then click off, and now it's going to generate a number between zero and 20. If I play this again, my random rotation is going to be a lot more. But what if I wanted to go below zero? Well, then I can actually add in a second number, the first number that you type in will be the low-end of the random, and the second number will be the high-end. If I put in negative 20 and separate it by a comma, then I have the minimum and maximum random values, I can click off, and now it's going to randomly generate a number between negative 20-20, and fill that in on every single frame of this comp. That's one method, but let's say that this is going a little too wild, I don't want it to be so random. Well, there's another method called wiggle and this one you're probably familiar with. If you've ever used expressions, wiggle is probably something that you've come across, but to write it out, I'm just going to type wiggle and again, it autofills for me, I'll double-click to autocomplete. It puts the cursor right there between the parentheses for me. Now, this particular expression does not work without any values between those parenthesis. I clicked off and it broke. Nothing is rotating and I even gets little error icon. If I click on that, it's telling me that I have a warning. After Effects, warning the expression is disabled. There's an error at line 1 in the property rotation of layer 2 expressions, income sourceRecAtTime. But the error down here is that the wiggle method needs between two and five arguments. An argument is what goes between these parentheses, those numbers we put on the random method, that was the argument. The argument was give me a number between negative 20 and 20. For wiggle, there is no default value like random at of generating a number between zero and one if nothing was written in there. I have to give it between two and five arguments. The two most basic required arguments are the frequency of this wiggle and the amplitude of the wiggle, and there in that order. The frequency, I want it to happen, let's say four times a second. That's what that value is measured in, the number of times per second. Then I separate that by a comment to give it the second argument, which is the amplitude, or how far this value can change with the wiggle, and I'll say 180 degrees. Don't worry about the other arguments that could be put in here. This is all I need for right now. I'll click off and play this back and now I'm getting a random number on every frame, but it's wiggling, it's kind of easing back and forth between values instead of just randomly giving me a unique value every single time. You can think of it like a smooth random. Now, I again want to reiterate that you do not need to know how all of this is working. You don't need to know all of the different expression methods and arguments and what they mean, and how many of them you need to have and what each one represents. This is something that you're going to learn over time and start memorizing as you use it. But if you ever forget, you can't remember what order these values are supposed to be in, there's actually a little cheat sheet in After Effects that will help you remember. Take a look at this little arrow right here. This is the expression language menu. If I click on it, this is the entire expressions library and it's separated out into categories. You see that there's a random numbers category and that's where we can find random. But underneath random, we also have random max value or array, as well as min value or array, max value or array and this is the cheat sheet part that I'm talking about. This is telling us what the arguments within those parentheses could be. If you put one number in, just one, it's going to be the maximum value that that random method is going to generate, and it'll return a value between zero and whatever you type in. If you'd put two numbers in separated by a comma, it'll be between the minimum value and the maximum value, which is what we did. If we search around here a little bit and go to property category, there's the wiggle expression. This is going to list out all of the different arguments that can be put into here, and this is actually something I should point out. Not every method requires that you use every argument, for wiggle, we just use the first two, which was the frequency and the amplitude. Three, four and five are much more complex. I've actually never even touched them if that tells you anything. But the point of this is that if you forget which one comes first, frequency or amplitude, just come down to the expressions, a library find the particular property or method that you were looking for and this will tell you exactly what you need to know. The other thing you can do is use Google. JavaScript is a massively used and documented code language and you can find really in-depth and clear explanations into any method argument calculation that you could think of online. Because After Effects uses the entire JavaScript library, if you see it in an expression, somebody has talked about it on the Internet and you can find explanations very quickly and easily just by Googling it. Let me undo and get back to where we were controlling just one property by the other. Let's take a look now at how this expression is written and what exactly After Effects is getting out of it? Well, first of all, I want to point out all of these periods, these dots, you can think of these periods as separators in a hierarchy and the overall line of code as a path. The first section of this code says this comp, this is the beginning of the path After Effects, is starting by saying where do I need to look for a value. We're going to tell After Effects, this comp, the comp that we are in, and that implies that you can look somewhere other than this comp and that's exactly right. You can actually reference properties in other comps. But for this example, we're looking at this comp that we're in, then we've got the dot, the periods separator, which is telling After Effects what's next. After we're looking in this camp, where do we look next. Then we are going to look at a layer, a layer within this comp and this next section in between parentheses and in-between quotes, we have a proper case name, white solid 1, which is exactly the name of this layer. That's how we're telling After Effects to look at a layer named white solid 1. Then we have another period. This period is the next separator. it's saying, what next. After we looked at that layer, what do you want to see next. Well, then go into the Transform controls. That would be this little drop-down right here, the Transform controls. We're looking at the Transform controls another period, what next? The opacity property, there we go. Opacity property 100. At that point After Effects is like, "Okay, I know what I'm looking for now, the opacity property value." I'm going to take that value because there's no other expressions or code after that, I'm going to take that value and plug it straight into the property that this expression is written on, which is the rotation for that text layer. Again, you do not need to know how to write out code like this. It is not something that I do regularly, either I use the property, pick whip or the expression pick whip constantly. But it is really helpful to understand the structure of an expression so that you can identify problems if things start to not work and you can better read what's being written inside of this code window. That's the very basics of expressions and how they function inside of After Effects. Don't worry if you're feeling overwhelmed, I can remember back to when I started using expressions, I was completely turned off to the idea of using code in my motion graphics. But once you actually start using them and you see the power and the possibilities that they open out inside of your designs, you're never going to go back. Don't worry if you've never used them before. If this was a very overwhelming video, that's okay. The rest of this class, we're going to use this very specific expressions and I'm going to walk you through each one of them very slowly. We're going to do a lot of repetition so that by the end of this class, you're going to feel totally comfortable implementing them into your own designs.
3. Variables: In this lesson, we're going to take a look at variables. You can think of a variable like shorthand inside of your expressions. It makes everything a lot more efficient, and it even makes your code easier to look at and just be able to read through. Let's take a look at an example. We're not going to do anything too exciting, but just to demonstrate what a variable is for, let's go into the transform controls and again go into the rotation. Let's start writing an expression here on the known ALT and clicking on that stopwatch. I want to give myself a little bit more room here, let me just expand this up. In that way, this is just a little easier to see. Now, like I said, a variable is like shorthand within your code. Let's say that I want to drive the rotation by the opacity property. When the opacity changes, the rotation also changes. Or we could do it the same way that we did before, which would be using the expression pick whip, and then selecting the opacity value and just clicking off, and then after effects we'll fill in the expression it needs to reference that property. In the transform controls we're looking at the opacity. By the way, the reason why we don't have this comp, this layer, all of that extra stuff is because it's on the same layer. We're looking at the opacity property for the same layer. After effects it's automatically assuming when we don't add in that, this comp.layer and then variables, it's assuming all of that is already there, when you don't add any of it in. If you are not telling after effects to reference a different layer or a different comp, then it's going to assume that we're dealing with the layer that you are writing the expression on. Anyway, let's just apply that, and now the rotation is directly corresponding to the opacity level from 0-100 degrees. But I can also store this code in what's called a variable. Let's see how we can write that. Well, I'm going to leave this as it is and go before that code and type in var for variable and then a space, and then I need to give it a name. This will be what we use as the shorthand. For opacity, I'm just going to use the variable o, just a lowercase letter o, and then another space equals space and then at the very end of the line, I'm going to put a semicolon, and that's how you end a line of code in an expression. But altogether, this is just saying that I'm defining a variable, I'm calling it o, and that is going to equal the opacity transformation value whenever I reference that letter o, that variable, further down in my code. If I apply this I'm actually going to get an expression error, because this is not a valid expression. It's not giving after effects any value, it's just a bit of code to reference another property. If I click on this, it's going to give me the error right here, saying that there's an undefined value used in this expression, meaning I'm not giving it a value with this code. What I need to do is drop down a line and maybe two just to give myself a little bit more room, and then put a value in. This can be a hard-coded value. If I put 90 and clicked off, it's going to give me a value of 90. But I want it to be the opacity value and I defined that as the letter o. If I just select that 90 and I type lower-case o, and put a semicolon to end that line of code, click off, there we go. That is now giving me the same value that I had before when I just used the expression pick whip. Now, this on its own, obviously it's not saving me anytime by defining that variable and then referencing that variable, because all I'll have to do to get this particular thing to work is to grab this expression pick whip and click on opacity, and it does the exact same thing. I'll undo that. The power of this is when you're using much more complex expressions, which we're about to get into. Having this shorthand that makes it much easier to just look at your expressions, so you don't have long lines of code to wade through and get confused by, and it makes it a lot easier to write your expressions because you're just using whatever you define your variables as. Now I realize this might all seem pretty abstract at this point. We're using very simple examples and they're not really doing anything. But trust me, once we start implementing them into our motion graphics templates, it's all going to make sense and you're going to be really glad that you knew about them before.
4. sourceRectAtTime: Now, we're actually going to start building our motion graphics template. It all starts with the sourceRectAtTime expression. This expression is a little bit confusing even if you've used expressions before because it can give us lots of different values, but those values are very important for what we're going to use it for which is sizing a rectangle, to a text layer no matter what's typed into it. So this is what allows us to give the user of our template the ability to edit a text field and have the design update the way that we want it to look. No matter what's typed in there, the box is always going to size to that text. So don't worry if you're a little bit overwhelmed already with expressions, I'm going to walk you through this very slowly and we're going to reuse it a lot. So let's take a look. Now before we even dive into that, I just want to point out something about JavaScript and expressions. This starting with a lowercase letter and then every word after that being capitalized is called camel case because it's like camel humps coming up and down. That's a very common way to write your expressions, but it's also the way that most methods in JavaScript are written, starting with a lowercase and every word after that being capitalized. So that's the technical syntax of how this expression is written, but what exactly does it mean? Well, sourceRectAtTime is just the name of the method and it means it's giving us the source rectangle at a given time. The source rectangle is the bounding box of any layer. So these transform controls, if it connected all of these dots, it would make a rectangle and the sourcRectAtTime expression is going to give us the dimensions or the size of that rectangle, but that's just the first half. There's also the AtTime half, which means if the size of this layer changes for any reason the contents change or say you animated this text, that source rectangle is going to update at the current time in your timeline. So whatever size it is at any given point, this will give us the value of that rectangle size. We have these parentheses here which allow us to add in some arguments. We'll talk about those in a little bit. But this on its own actually isn't going to give us what we need because there are four different properties that we can pull out of sourceRectAtTime, and we need all four of them for this to work. Those values are the width of the rectangle, the height of the rectangle, the left value, and the top value. So width and height makes sense. It's the width of the box and the height of the box. But what are the left and top values and why are they important? Well, if i zoom in here, nice and close on this text layer, you'll notice that the anchor point for this text layer is in the bottom-left corner. For any other layer, it's usually right in the center of the layer. But the reason why this is in the bottom left is because this text layer is different than a solid layer or a shape layer. You can type in it and as you type, it goes from left to right because my paragraph is set to left justify, I can align this to the center and then the anchor point is aligned to the center horizontally, but vertically, it's still down in the lower part of the text layer. If I right justify it then it is on the right side, but still offset down vertically. I'm switch this back to left justified. Let's talk about why this is. Well text and typography in general has what's called a baseline. The baseline is basically where your text is sitting. Now this is a stylized font, so it's not very symmetrical. This leg on the A, is lower than this leg. But if I zoom in really close. You can see that that anchor point is pretty down close to where this first leg of the A is resting. If I bring up my rulers by pressing control or command R, and then click and drag to make a guide, align it with the anchor point for this layer right there in the center of that anchor point. I want to be super precise to illustrate this. So there, my anchor point is now centered up, align perfectly with those guides. You'll notice that a lot of these letters are resting right there on that guide. This is the baseline for the text. Characters for fonts are designed on top of this baseline of for alignment. So that's where after effects puts the anchor point for a text layer vertically. While it does look like the anchor point is aligned horizontally with the left edge of this text layer, it actually can be slightly off and it's not very visible with this particular character. But if I try a different character like a Y, and then I pan up a little bit, you can see that the tip of this Y on this arm right here is going beyond that anchor point. So I like to call this horizontal point the origin of the text layer. This is another guide that the type designer designs there type off of. Some characters will overlap it, others will align to it. But after effects is placing this anchor point at this position because that's how the type was designed with that point in mind as the origin of a text layer. Understanding that is going to be very important in just a little bit. But now that we understand that, let's just get back to our text layer. I'm going to get rid of my guides and hide my rulers, and let's center this up again. So I'll just get that right in the middle and let's make a rectangle. So I'm going to go to my rectangle tool and double-click on it. I'll drag it below of this text and right there is good and I need to get to the size of this rectangle. So go into the rectangle group, into the rectangle path, and here I have my size and position. These are the two properties that we need to add expressions to in order to get this text box to size to this text and stick with it no matter what. So first let's just work on the sourceRectAtTime width and height, and plug that directly into the size of this rectangle. So to add an expression, remember you hold down Alt or Option on a Mac and click on that stop watch and then we can start writing the expression. So let's say sourceRect and after effects auto completes the rest of it for me, I'll double-click on it. So we have sourceRectAtTime, open and closed parentheses. I don't need to put anything inside this just yet. But I'll go after that closing parentheses and add a period, which remember is like a separator in the hierarchy. So after effects is seeing, you want me to use sourceRectAtTime and then what? Well, I want you to find the width and that's it. I just want the width property, and I'll close this off with a semicolon and apply the expression and nothing happens. I actually I'm getting an error. This is actually for a couple of different reasons. For one sourceRectAtTime.width on its own isn't giving after effects enough information. It needs to know what source rectangle we want it to pull from. In this case, we want it to be from this text layer, and I didn't specify that. So let me give myself a little bit more room to view this. I wanted to find a variable for that text layer. So let's do that. I'm going to go into this expression and then just before the source rect at time expression that we wrote, I'm going to drop down a line and at the top type in VAR for variable space and then I'll call this TXT for text. Remember you can name that however you want. I'm just going to make it easily identifiable as TXT for text and then space equals space. I'll use the expression pick web to click and drag to the text layer. I don't need to go into any of the properties. I'm just telling you after effects, this is the layer I want to be referenced. I'll let go of that, it fills it in, I just want to make sure that I finish off that line with a semicolon. Now I have a variable for that text layer. Next I need to go at the start of this line of code and type in txt. to start off that path for After Effects telling it, " Look at that text layers source rect at times, width property." Now I'll apply that, and I still have an error. We solved one problem, but we still have another one. Let's find out what that error is. If I click on this warning sign, it's letting me know the expression is disabled. Down at the bottom, it's saying that the expression result must be of dimension two, not one. What this is saying is I'm only giving it a one-dimensional value, but I need it to have two dimensions and that's because my size value is actually two different values, a width and a height. If I'm calculating a single value, it breaks because after f_x is expecting two values. This is called an array. Any property that uses more than one value. Let me show you how you write an array in an expression really quickly. I'm just going to select this entire line by triple clicking on it and then cutting it. Control X or Command X on a Mac, and instead of an expression, I'm just going to write a hard-coded value in an array. To do that, I'm going to press the left square bracket, after-effects will automatically put a closing square bracket for me just, so I don't forget, that is something that you have to do. But now I can write two values within these brackets. Let's say I want the width to be 400. I'll type that out and then I press "Comma," to separate the two values in the array and for the height, let's say I want that to be 150. I'll move over and end that with a semicolon and apply this. Now my rectangle size is 400 by 150. Exactly what I typed in here. It's not using this variable and the expression that I cut isn't being evaluated obviously. But this is how we write an array, square brackets and two values separated by a comma. If it was a three-dimensional property, if it was a 3D layer, then you would need to do three numbers, each separated by that comma. Now that we know how to write this array, I want to swap out this first number, the width of this size property with that expression that I had cut. Let me paste that back in now Control V or Command V on a Mac, and now we have that variable for this layer SourceRectAtTime width within this first value. I just need to make sure that I take off that semicolon, because that only goes at the very end of your line of code. In the width, we should be getting the width of the text layer that we're referencing and the height is still set to 150. I'm just going to do some housekeeping really quick before I apply this and drop it down one more line. That's just how I like to write my expressions of variables separated by one line from the actual expression. But now we can click off that is applied and look at that. The text box is the exact same width as the text layer. Now it's not aligned perfectly, but if I just move it around and hold down Control or Command on a Mac, I can snap it to the very center of that text layer and it's aligned now. If I click off of it, you can see that is perfectly aligned to the size of the text. But what about the height? Well, let's go back into our expression and just copy what we have here and paste it in place of this hard-coded 150 value. I'll paste it there and all I need to do is change width to height, and that will pull the height value out of the source rectangle for that layer, I apply it, and there we go. Our box is perfectly sized to that text. But if we take a look at this expression one more time, this isn't all that easy to look at and identify. It's a long line of code with a bunch of repeated texts. We can actually clean this up quite a bit if we use some more variables. One great thing about variables is as soon as you've defined it, you can start using it on the very next line. I'm going to add another variable drop-down, say VAR space, and then I'll name this w for width space equals space. And what I want here is what I have down here in my array for the width. I'm just going to cut that and paste it up here. Finish that line with a semicolon and then I'm going to drop down again VAR h for height space equals space, and then select this text, cut and paste it up here, finish it off with a semicolon. By the way, all of these spaces is purely for visual organization. JavaScript does not pay attention to spaces or a line breaks. You could have all of your texts on one line with no spaces and it would be able to read it just fine. But as a human, it's much easier to identify and visually organize your code if you space stuff out and break it up by lines. But back to our expression, we have all three of our variables for the text layer, the SourceRectAtTime width, and SourceRectAtTime height. Now we have an empty array, but I can just plug in w for width and h for height. Apply it. Nothing changes. It gives us the exact same result, but it's much easier to read our actual expression. Now, all the complicated stuff is up here in our variables and it's all organized by line. It's easy to pick out and modify if we need to. I can actually clean this up even more if I take the source rect at time part of the expression in each one of these variables and cut that and included it in the source text variable, I'll just paste it right after text. Now I can get rid of that source rect at time on both the width and height variable and it's much easier to read now. Now I'm just looking at the text layers width and the text layers height. That might seem a little bit pointless, but it allows me to then modify what's between these parentheses on the source rect at time method for both of the following variables, which we are going to need to do in a little bit to get our box to work properly. You can think of these variables as precomps. It's a way to store information that you're going to reuse over and over again. Just like animating with precomps and makes an animation faster and more efficient. Variables can make expressions much more efficient. If I click off of this and to apply it, you'll see that we get the exact same result, but it's just a much cleaner block of code to look at. The variables are very easy to identify and our array is extremely simple. We've got the text box size to the text layer now, we should be able to type something else in here. Well, let me just edit this text layer and say something else and, well, that's not exactly working, is it? First of all, if I move my text layer around the box is not moving with it and you saw that this inbox was expanding, but it's not the same. That's because texts layers or at least this one is left justified, It's expanding from the left to the right, and that left point is never moving. But we're just adding an expression to, the size property of this rectangle path, and if I disable that expression really quickly, by clicking on this little blue equal sign that enables or disables the expression, and just adjust the size width. You can see that rectangle's size from the center of the layer, not the left edge. That actually makes sense. This expression is doing what it's supposed to be doing right now, which is size of the box to the size of the layer. It has nothing to do with the position of the box. We only have part of the problem solved. Let's re-enable that expression and I'll type this back out to just saying text, so it's a little bit smaller. Let's take a look at the next issue which is getting the box to follow the text layer. Well, this is really easy. I just need to first align it and hold down control to snap into the center of the layer again, so it's perfectly aligned with that text and then I'm just going to parent this layer to the text layer. Now wherever the text goes, the box goes with it. Let me just rename this text box just for organization and I'll show you the next issue. If I go to the character panel and do something like maybe switched it to all caps. See that text box shifted over to the left and if I change the size of the text, it's scaling from the center of the layer again, but the text layer is scaling from its anchor point. Again, this is exactly what should be happening. The only property that we've added an expression to is the size. How can we get the positioning working? Well, let me undo getting back to where we have this nicely aligned text and I'm going to collapse up the size property just so we have more room. Just below the size is the position property. This is what we need to be able to shift the box around left and right and up and down and because this layer is sizing from that anchor point, remember that origin for the text layer align to the baseline in the left edge that origin of the text, this is where the sourceReactAttime, the left and top values are going to come into play. The left value is the distance between the left edge of the text layer and the origin of that text layer and the top value is the distance between the top of the layer and the baseline. If we know those two values, then we can change the anchor point for this text box, specifically the rectangle path to be not in the center of the layer, but aligned to the origin of that text layer and I'll show you how we do that right now. Let's go into the position and add an expression. Now we actually can reuse a lot of the expression that we already wrote on the size. Let me just go back into that, and I'll just copy all of it. Copy and then go back into my position expression and paste. Now this is not going to give us what we want, this is taking size values and plugging it into the position, not what we want. Let's go back into that expression and start modifying some things. First of all, this first variable can stay exactly the same. We want to reference the text layer sourceReactAttime but for the width and height, we need to modify this a little bit and to explain this a little bit more easier, I'm going to just make a new rectangle and I'm going to size it to 100 by 200, and we're going to move this up here so we can just focus on it for a second. Let's go into that Rectangle, Position and Size. These are the two values we need to worry about. As I move the position around, you'll see that the anchor point stays in the center. What do I need to do to get this to be in the top left corner? Well, if we take a look at these two values between the size and the position and how they're related, it looks like half of the size will be the position that we need to get that to be aligned, which makes sense. Half of the width and half of the height from the center of the rectangle will get us to the top left corner. Another way that I could have done this is just said make the position half of the size. In an expression I could just use the property pick whip to select the size and if we open this up and take a look, you'll notice it's not giving me any errors even though we just have one line of code. This is an array, so you'd think we need two numbers. Well, if you add an expression to an array and you reference another property that is also an array with the same number of values, then we don't have to write it in an array. It's automatically going to pull the first value into the first value and the second value into the second value. But you can see the anchor point is up here, and my rectangle moved down into the right because it's just pulling the exact same numbers. I want half of that. At the end of this line of code, I'm just going to say divide it by 2 and then apply it and there we go. Now that top-left corner of the rectangle is aligned to the anchor point of the layer. If I size this now it's going to scale from that top-left corner. That was the illustration, now let's actually implement it into our text box. Right now it's scaling from the center, but we want it to scale from the top left corner. Let's just go back into our expression and add divided by 2 to the end of the width and the height values for this sourceReactAttime. That's all I need to change, if I click "Off", the rectangle is now aligned its top-left corner to the anchor point for the layer. Now it's not aligned at the text anymore, so I do need to click and drag again, hold down control, and snap it to the center but now there we go, top-left corner, it's aligned. But we're not done, that's just the starting point. We don't want it to scale from the top-left corner, we want it to scale from where the anchor point is on the text layer. Well, remember that dot height part of sourceReactAttime, because it gives us the difference between the height of the layer and that baseline, and right now our text box is aligned to the top left edges of this text layer, so it's already at the starting point where we measure the distance from, on the sourceReactAttime.left and the sourceReactAttime.top. Let's factor those things in to our expression. I'm going to drop down another line and add a variable that is l for left, space equals space txt.left; and remember that's this entire line of code, and then we're just adding the.left, and then I'll drop down another line, var, t for top, space equals space, txt.top;. Now I have those two variables and I can factor them into my array. We want to take where that anchor point is right now and add to it the left value that this variable right here is going to give us. I'm going to say width plus l for left and height plus t for top. If I did everything right, I'm going to apply this and it should work. Now the text box did move up, but if we click on it and take a look, the anchor point is in the bottom left corner now, and that is what we want. If I zoom in real nice and close, you can see it's not perfectly aligned to the bottom left corner of the box, but neither is the anchor point for this text layer. This looks like it's working. Let's shift this down one more time. I'll grab it, click and drag on that anchor point and hold Control or Command, snap it to the text layers anchor points, and now let's try typing something else. Something else. Look at that. The text box is perfectly aligned to that text layer. If I make it all caps, if I change its size, if I change its justification, it's always going to stick to that text because we're basing the position off of the baseline and origin of that layer. Between sizing the box correctly and positioning it correctly, this text box is always going to go exactly where it needs to. But you might be thinking that doesn't look all that great, I don't necessarily want it to be exactly size to that text layer, and you're right. This is just the base foundation. Think of it like building a house. It's the foundation layer that we can then build on top of. To make this text box a little bit bigger, since this is a shape layer, all I need to do is go into the Contents and add Offset paths. Now, I have this very easy to control slider basically to increase or decrease the margin for my text. Again, this will change based on whatever you put into this text. It will dynamically update to always fit to it and because it's a rectangle, I could even go into it and say round it off if I wanted to be more like a pill shape, it's as easy as that. But this is the real foundation of how we're going to build dynamic templates that respond to whatever is typed into them. I know that was a whole lot of information thrown at you, hopefully you are able to absorb it and it makes sense. I think at this point, if you're up to it, you should start getting in After Effects and trying to recreate what I showed you how to make, watch through it with me. You can slow down the playback speed or just be pausing it but you should actually try and code this for yourself so you can see what things might trip you up and how you can get it all working together to actually make a box that sizes to the text. Now you might be thinking this isn't what I want my template to look like, but the reality is with a text layer and especially with the lower third, you're almost always going to have a rectangle behind that text layer, or maybe you want to add two lines. Well, we're going to get into that in the next lesson. So don't get too hung up on the actual look of your template at this point, just know that this is really fundamental for making a motion graphics template that is dynamic enough to give to somebody so that you know it's always going to look the way that you want it to. But go ahead and jump in there, start writing your own expressions and get to the point where you can have a rectangle sizing to that text layer, no matter what you do to that text layer. Good luck.
5. Animating With Expressions: Now that we have this working foundation, we can actually start animating it so that it's really a motion design. So let's take a look at how we can work with expressions, so that they'll allow us to animate something that's dynamic like this. I'm going to really quickly add a text animator onto this layer, which if you're not familiar with text animators, check on my class, The Ultimate Guide to Text Animators in After Effects, where I teach you absolutely everything you need to know about them. But I'm just going to do a very simple scale animation. I'll add that and then modify this just a little bit. We're going to change the "Scale" down to 0. So it scales all of my characters down and I'm going to change the "Range Selector" inside of the advanced controls from "Square" to "Ramp up."Now as I animate the "Offset," I can wipe this on. So let's go to the beginning of the comp, set a keyframe at negative 100 on the offset, and then go forward maybe 20 frames and turn this all the way back up to 100 percent. Now this is going to animate on, and I can make this a little bit nicer, if I grab the "Ease Low" and crank that up. That's like the ease out for each one of the individual characters. So that now animates on really nice and the box follows it. Because remember we have SourceRectAtTime. So the source "Rectangle" for this layer at this given time is this size and as we move forward, it resizes dynamically. That's great, if that's what you want it to look like. But let's say I don't want that box to scale up with the text, I want to animate it independently of the text and just have it resolve or end up the right size no matter what text is typed in here. Well, that's exactly where that the opening closing parentheses on SourceRectAtTime comes into play. So let's dive back into our expressions. The really easy way to bring them up is to select the layer that has the expressions and double tap the "E" key. So I'm just going to tap "E" "E", and that brings up all of the expressions for that layer. I don't need to worry about the position right now, I'm just concerned with the size, so I'll collapse that up. Let's jump in here. In between the two parentheses, this is where we can determine at what point in time we're reading the source rectangle value. Now, by one second into my comp, my animation on the text is complete. So why don't we just start there as our reference point. We want to get the source rectangle at one second in this comp. So if we go back into our expression in-between those two parentheses, I'm just going to type one because it's Time Value is measured in seconds and just click "Off". Now if I scrub my animation back, well, it's doing something, but it's not doing exactly what we want. It's the right size the whole time, but it's moving around. That is because our position value actually does need to be modified a little bit. If we go into it, this is also using SourceRectAtTime. So all I need to do is go into this expression and add the one to that SourceRectAtTime as well. If I apply that, now that rectangle is going to stay the size that it's supposed to be at the end of the animation and it will not move because it's grabbing the SourceRectAtTime value at one second and ignoring all the other time in the timeline. But watch what happens. I'm going to bring up the keyframes by pressing "U" with that layer selected. If I grab these two keyframes, and scoot them past the one second mark, as soon as I do, that box starts to get smaller again. It's because the SourceRectAtTime value at one second is no longer the end of the animation. So the box is looking at basically a rectangle value of 00. Now, if I move these back to the start and I actually move the entire layer, you're going to notice the same thing is not true. Because this AtTime value is actually relative to the layer, not to the comp. So this is one second in to that layer. You might not have known this, but every layer has a start point. To prove it to you, if I extend this back in time, you see that we have these tiny little hash marks. They're just letting you know that this is extending beyond the starting point of that layer. So even if I do that, it's not affecting the time value. This would technically be negative time on this layer. So moving this layer around in time doesn't affect the expression. It's the keyframes within the layer relative to the endpoint or the starting frame of that layer that matters. But now that I have that set up, I could animate the rectangle independently of the text. So why don't we just move this text layer out of the way, and say that I want this to scale up from the left side to the right side and then have the text animate in. Well, let's take a look at the structure of this layer and see what a good way to do this might be. If we go into the "Rectangle" group and I'm going to rename this really quickly and call this text box group, just so we understand that is a group, it's not a shape. Because every group in a shape layer has its own transform controls. The rectangle path itself, this shape has a size and a position. Those are unique values to the rectangle path shape. But any shape group has transform controls.So instead of messing with the size or position values that all ready have expressions on that rectangle, I'm going to use the transform controls of the shape group to animate this on. Let's take a look at the Scale property. I want to unlink the x and y and animate on the x. Now it's all ready basically doing what I wanted to because the anchor point is near that bottom left side. But again, it's not exactly where it needs to be because it's based on the text layer's anchor point, remember. So what do we need to do to get the anchor point for this shape group to be aligned not only to the left edge of the rectangle, but also to the left edge of this margin that we included? Well, we're going to use some of the same expressions. First of all, I want the position to be whatever the anchor point is. Keeping those two values the same, will prevent the shape group from actually moving around on screen. Let me show you what I mean. If I offset this by, say, 100 pixels on the position. Let me type that in. Then I also offset the anchor point by 100, then it's right back where we started. So since I want to move that anchor point around to get it to line up to that left edge, I'm just going to use the property pick whip, and grab that anchor point value so that the position value is always identical to the anchor point. If I move the anchor point around now, the shape group itself does not move. Let me zero that back out. How do we get this back over to the left edge? Well, we need to write an expression. So let's hold down "Alt" or "Option" on a Mac and click on that stopwatch and write in some variables. Actually just like before, we can reuse some of the same variables. So let's go into the rectangle path, into the position, and just copy all of the variables that we have here. So the source text, the width, height, left and top values from source wrecked at time. I'll copy that, go back into my new expression and paste. So these are just the variables, what do we want the array to be? Well, we need to account for this offset value, which is being driven by an offset pulse. We actually need to add that variable in as well. Let's drop down a line type "VAR," and I'll just use o for offset, and then we need to find that value. I'm going to get an error for a second while we find this. But there it is, offset paths, and I need to use this amount value. So under that variable, I'm going to use the expression pick whip, grab the amount and close that off with a semicolon. Let's collapse this down so we can see what we're doing again and start writing our array. So I'll start by writing a left square bracket After Effects finishes off the right one. For the x value on this anchor point, I want it to be the offset value minus the left value. Remember the left is the distance between that origin point and the left of the text layer. So I'll say o plus l. Make sure to finish that line off with a semicolon. Then I'll do a comma for the second value and for the height, let's just leave it a hard-coded zero for now. I'm not going to be animating that, so leaving it at zero is actually fine. So let's apply that and see what happens. The box didn't move, so that's a good sign, but let's zoom in here with this selected. We can see that anchor point is not where we want it to be. It's on the right side, we want it to be over here on the left side. That's because the positive axis directions are right and up. So adding positive values of the offset and the left is actually pushing it in the wrong direction. So I actually need to subtract the offset. The "l" can stay the same, that left edge value should be added. But we need this o to be a negative number. So I'm just going to go back into my expression and type a minus before that o, and we're going to get a negative offset plus the left value. If I apply that and look at that anchor point again, I'll zoom in nice and close, and look at that. It is 100 percent perfectly aligned to the left side of that rectangle, including our offset paths. Even if I go down and I increase that amount, the anchor point is always going to stick to that left edge now. What that means is that the shape group, which contains the rectangle path, can now be animated on that scale property from the left edge and that left edge will not move. So that's exactly what I needed. Let's set a keyframe on that scale and just press "U" and to show just that keyframe. I'll bring this maybe to 20 frames in. Then at frame one, I'll change the x value on that scale to zero. Play that back and now we've got this scaling up. I can make this look a little nicer, if I go into the graph editor, make sure I'm on the speed graph, and then grab this handle and make this a nice sharp curve. There we go. So now we have this text box scaling out to the size of the final animated text. If I bring that text layer back, I can now time this to start animating on, even at the same time that the text box is. There we go. We've got a working animation and this will dynamically update no matter what I type in here. So if I said "Skillshare," it's going to animate. If I made it a shorter word like top, it's still going to animate out and that rectangle is going to resize no matter what. This is where things start to get really fun because we can start playing around with the design and create graphics that are based on the shape of the text that they're behind. I could add a second text box just by duplicating this, since all of those expressions are going to copy over as well. I'll call this one "Accent Box." and we'll move the text box and the text layer forward in time just a little bit so we can focus on this first one and maybe I'll change that fill color to be the same color as the texts. Something like that. Let's just get that exact color so we're consistent. Now we're going to have this first box come out and I'll just give it a couple of frames, maybe two frames, and then bring the next box out. So now we have that nice little accent line coming out to start. Again, I can change this to my name, if I wanted to, and scale it down a little bit so it fits on the screen, reposition it, do whatever I need to, and it's all dynamic. While I do think that it's really important that you understand exactly what's going on here, that's why I spent so much time trying to give you as much detail and explanation as possible into these expressions, the reality is, once you have this built, you never have to redo this. You can save this project file and use it like a template moving forward. In fact, you can come up to "File", "Save As" and then change the type from After Effects project to After Effects template project. What this will do is save an After Effects project that when you open it will not modify this template file. It will create a new project based on whatever you saved within this template. So you could just save this as the text box template and it will be the foundation for whatever design you want to create from that point. So it is important to understand how this is all working, but you don't have to put in all of this work every single time you want to make a template. I really hope that you're able to see the possibilities that expressions are opening up inside of After Effects. In the next couple of lessons we're going to push this design even further to turn it into a lower third. I'll have a little bit more animation to it, some more features and we're even going to stylize it a bit more. At this point, you should get in there and try to animate this for yourself and make sure that it's all updating properly when you change the text layer, change the font, anything that you do, that the animation is preserved. Don't get too hung up on the design of the template at this point. It's fine that it's just a rectangle behind text. In a few lessons, we're going to take a look at how to stylize this and how you can actually turn this into something that looks a little bit more fun than text on top of a box.
6. Building a Lower Third: Now, that we have this dynamic box and linked to our text, let's turn it into a lower third. I like to use my title in action saved guides for alignment for this, it's a good practice. I'm just going to go to my little guide and grid menu and find the title action saved guides. The apostrophe key on the keyboard is the shortcut to turn that on and off, and this rectangle right here is the title safe box. For broadcast on television, it's general practice to not have texts outside of that box and just in case anything is cropped off on people's displays. But it's also just a good buffer between the edge of the screen and where you want to read this text. Now, I want this to have two lines, not just the one line of text. This text is not going to sit rate on this guide and it's probably way too big. Let me just scale this down a little bit and let's type in my name. I'll just use my name as an example and I'll zoom in nice and close and point out that my anchor point is not touching this title safe guide and that's because remember some characters could overlap that anchor points. I'm just giving myself a little bit of buffer. It's okay that that box is going beyond it because it's not the actual text. It's just what needs to be read should be within those guides. How did we get a second line on here? Well, I'm going to just duplicated what I have already and make a few modifications. I'll select both the Line 1 text and a Text Box 1 shape and duplicate them Command or Control D, and I'll just group them up at the top for now. I'll just double-click the text layer and say motion designer. This text box obviously isn't following this new text layer and that's because expressions don't update when you duplicate them. They're still referencing this first line of text. The only reason it's moving with it is because the parenting relationship does carry over when you duplicate. It assumes that I want these two duplicated layers to preserve the parent-child relationship that the original two already had. We need to modify some of the expressions in here. Let's double tap E to bring up all the expressions and take a look at what we need to modify. Well, before I even go into any of these, you can see that the first variable and these three expressions all use the source text of Line 1 right here and because they're all nice and organized, all I need to do to get the box to be sized and aligned to this second text layer is going to each one of these and change the layer name from the Line 1 to Line 2. I'll just do that for each one of these expressions. All the variables are now referencing that second text layer and just like that, my textbox is now animating and sizing and aligning perfectly to this second line. From here I'm going to just scale this down a little bit, maybe I'll make this 48 points and bring it down below the other text layer, I'm holding shift while I move this to constrain it to the y-axis when I'm moving. Maybe I wanted about there, what I want to do next is make sure that it's aligned to this text layer on the horizontal axis. I'm just going to parent Line 1 to Line 2 and press "P" to bring up the position and see that the x value is now zero, which means it's the same value relative to Line 1. I can know for certain those are aligned and it's 85 pixels down on the y-axis from the original text layer. I'm just going to move my text box to layer down below Text Box 1, so it doesn't overlap that original text layer and I need to make sure I give myself more room than this. Because remember, some letters have descenders, so if I put a lowercase g right here, that little leg on the g is a descender off of the baseline, which looks pretty cramped into that second line. I'm going to bring that down a little bit more, just give it a little more breathing room and that looks pretty good. But I want to point out that right here, if I zoom in nice and close, there's a little discrepancy between the two text boxes. The new textbox is just slightly to the right and that's because of the source wrecked at time left value. The left value for this text layer is different than the left value for this text layer because there are different characters. Remember, it's dependent on the first character in the line of text. For this second box, instead of taking the left value from this text layer, I wanted to take it from the first text layer so that this is always perfectly aligned on the left edge. Let me double tap E on Text Box 2 one more time and we don't need to worry about the size of the box, we want that to stay the same. But it's the position and the anchor point that are going to need just a slight modification. Let's go into the position expression and I need a variable to reference that first line of text. I'm going to just duplicate this first line. So triple click on it to select the whole thing, copy, drop down a line and then paste and I'll get rid of that extra line, and we're going to call this variable Text 2, just for simplicity, and we need to change Line 2 back to Line 1. This is the original text layer that has my name in it. Then we just need to use that source for our dot left property. I'll come down to the L variable and change text to Text 2. Now, we're getting the source wrecked at time dot left value from the original text layer that has my name typed in. While I'm here, I'm just going to copy all of this because we're going to then apply it and do the exact same thing for the anchor point. You can see already that that seam is gone there now perfectly aligned. But now I need to change the anchor point is so that the animation happens off of that edge. Because if I backup right here, it's very subtle, but you can see right there at the beginning of that animation, it's not scaling from the right place. Let's go into that anchor point property, go into that expression and I'll just replace everything above this offset variable because this one was not part of this expression. But I'll just paste here that adds in that extra line, changes L to Text 2, if I apply this, now everything should work perfectly. It scales off of the right point and it's aligned to the left edge properly. That solves that problem. From here we can play around with the way that the animation plays out, right now both lines are animating on at the exact same time. I could grab Line 2 and Text Box 2 and just scoot them forward a little bit and then they're going to offset, That's cool. My first line has that accent box that we put in. Maybe I'd want to duplicate this text box and call it Accent Box 2 and then I could grab that same color and paste it and then just scoot the second line forward a little bit in time. I think it was just two frames, there we go. Now, we've got that accent box on each frame. Now, I would suggest that you trim off any layers that are hidden once the animation is finished. These two accent boxes, once they're completely covered up, which would be at the end of the text boxes animation, so rate there. I'll trim this off, just so it's not sitting there anymore and same thing for this one. I'm going to go to the second textbox to where that is fully animated on and trim that accent box off at the same place. Cool. Now, let's say that I'm happy with the way that this is looking, except I want to modify that margin. Well, now that I have a bunch of duplicates, I would have to go into every one of these boxes and modify that offset paths operator to do that. Let's actually start building some controls to make these adjustments a little bit easier. I'm going to make a null by going up to layer a new Null Object and I'm going to name this controls. On this layer I'm going to add an effect. I'll go up to Effect down to Expression Controls and these effects do absolutely nothing on their own. They are just there to control expressions, which is why they're called expression controls. The offset pads amount property is just a number. We're going to control this with a slider. I'm going to add a slider control and it looks like this. It's just a slider value and it gives me a number, does not do anything on its own, it's just a number value. Let's name this, offset amount. I did that just by selecting the effect and pressing ''Enter'' and then typing pressing ''Enter'' again. Now, I want to keep this effect visible, even when I click on another layer, you see as I do that, it goes away. So with this layer selected, I'm going to click on this little lock icon under the effects controls panel and now even if I click off of that layer, it's going to stay up here and be visible. That's helpful because now what I want to do is search these four layers. I'll select all four of them for the amount property and you'll notice this brings up even the expressions that have that term in it. But I want to find this offset pads one on each one of these layers and what I'll do is link this amount value to that slider control. Using the property pick whip, I'm going to click and drag and come all the way up to the effects controls. This even works in a different panel, so I'll just select that slider, let go and now that value is being driven by this slider. If I increase it or decrease it, we can see that happening. I'm going to set that to 15 for now, just so I can see the difference and then let's do that for the other boxes. Under offset paths amount for the next box, I'm going to use the property pick whip to gram that slider, easy is that and I'll do that for the remaining two boxes. Now, all of those are linked up, I can use this slider to adjust that offset paths and it might even be a little bit easier if I twirl this down and I can go from 0 up to 100. If you wanted to change that value for any reason, you can just right-click on slider and say edit value, and you can change the range of this slider. Now, I don't need to do that, so I'm going to leave it exactly as it is. But now we have the ability to modify that margin on the fly from this controls null that we created. These aren't necessarily controls that we want to give to the editor who's going to be using this template in Premiere, but it's a really great way of working inside of After Effects. You don't have to constantly be searching for values, opening and closing layers all the time. Instead, you just have one central location for your controls. Let's add a little bit more personality to this animation, so it's not so static. I want to have this first box come out and then move up as this second line animates on. Right now, I can't really do that because this text layer is parented to the first text layer. Let's actually break that relationship. I'll just take that off and I'm also going to move the second line. I need to make sure I have all three of those layers selected, move them forward out of the way for a second. Again, what I want to do, is have this come out and then move up to this position. Maybe about right around this point is where I want it to end up at this point. I'm going to add a position keyframe by pressing Alt Shift P or Command P on a Mac and then back up, maybe 10 frames, Shift plus the page up key on the keyboard, and shift this down, maybe about there. On this part of the animation I might even have it slide out a little bit. Maybe a line that up with the text box animation so that it stops moving at this point. I'll add another key frame rate here and then go back to the start of the layer and scoot this back a little bit, not all the way up the screen, maybe just about to here and I actually push this keyframe back even before that layer starts so that it's aligned with the textbox. Now, I have this animation that comes out and up, I just need to ease everything. Let's go into that position property speed graph, easy ease everything and just bring these handles to be a little bit more extreme, maybe something like that and I'm just going to work on the timing a little bit. I don't need any easing out of that first key frame and the second movement is a little extreme. Let's space that out just a little bit more, give it some more time and modify this curve just a bit, that looks pretty good. At this point that it's moving up, is when I want the next text box to be animating in. Let's go to right about here where it starts moving and grab those three layers, bring it back and probably start it right about there. Now, we can play this back and see what it all looks like together. At this point I have a working lower third, which you can see right here. It's totally functional even though it is pretty basic. At this point, I'd probably want to go in and start tweaking things to make things more visually interesting and that's exactly what we're going to do in the next couple of lessons. At this point, you should go back into After Effects and if you need those two lines of text, make sure that you can get it to a working point, but play around with the way that it animates. Do different fonts, use different text animators, and customize it however you like. Then we can move on to the next lesson where we take this a little bit further and start customizing the way that everything looks.
7. Stylized Design Walkthrough: In this lesson, I'm going to walk you through how I took the template that I created up to this point, and pushed it further adding some more stylistic flair to it and some texture, a little bit more fun text animation, and just show you how you can really push this to look how ever you want. If you want to download this project file, you can just go to the Project and Resources tab, and look on the right side of the page and then you can walk through all of this and dissect how I made it. I'm not going to show you specifically how I made it, but I will walk you through what I changed and how it's still working. First of all, I just animated the text differently so it's randomly shuffling in these characters and those characters are being matted on the base shape, that textbox layer. The way I did that was just by using the set matte effect, which allows you to make a matte based on any layer. I chose the text box one layer, and I made sure to use effects and masks because that brings me to my next change, which was layering on effects. This textbox one, has a turbulent displace that's making it not so perfect. You can see I rounded off the corners of the rectangle, but then I added this turbulent displace to it. That's why you need to make sure that effects and masks is enabled on that set matte effect, so that it's paying attention to not only the layer, but also the effects that are applied to it. Behind that, I added this texture layer, which again uses set matte to keep it within the bounds of that box, but it is just an animated texture that looks like this using a turbulent noise effect. Then I also have this initial line that comes out, this just like a wiggly accent or line that leads out the whole animation. That was done modifying another copy of this base box. Let me show you how I made that really quickly. If I go into the contents, check out the rectangle, go into the rectangle path. Everything is exactly the same except within the size expression. I have a variable for the source text, I have a variable for the source rect at time, and I have a variable for the width. Not for the height though, because I wanted the height to be zero, so that this would just be a single line instead of an entire box. Once I had that, I could add a trim paths to the group, so that I could animate this line coming on and off. Let's just solo that for a second and turn off this zigzag. You can see that it's just a straight line animating out, but the width of it is based on the text layer, it will always align with that text box. Then I just added a zigzag and modified the properties so that it was a little bit more squiggly, and when you put all that together, you get something that looks like this. But just like everything else, I can change this text to say something else and it's going to update with it. Let's play this back, there we go. That line is longer, the box is longer. It's all dynamic and updates to whatever you type in. That's the key factor to making these templates work inside of premier. Now, that you've seen how far I pushed my design, I want you to get in there and started customizing your own design. Mine is very flat in 2D, but you could add lighting effects to it to give it more shading and more depth, or you could actually make it 3D. It's all being driven by those expressions, so it doesn't really matter what you do to your design at this point. You can make it look how ever you want. Because we laid all this foundational work, it's all going to update dynamically. Get in there, play around with it and have some fun. As always, you can ask me questions if you're running into any issues with your specific design. I'm always here to help.
8. Exporting Your Template: Now that my design is looking the way that I want it to, I need to actually turn it into a template. That's what we're going to take a look at in this lesson. Well, this is where the Essential Graphics panel comes into play. Come up to "Window", and mine is getting cropped off, but just go up to "Essential Graphics", and open that panel up, and mine is docked right here, next to my Effect Controls. I think this is a pretty convenient place to have it, so I'm going to leave it right there. What this Essential Graphics panel allows us to do is add controls that we want to give to the editor inside of Premier. The amount of flexibility that you give the editor is entirely dependent on your needs. Let's say that you're a motion designer designing a graphics package for editors to use. Well, then you probably have a style guide that you want those editors to adhere to, and you don't want them changing things like colors and fonts. You just want to give them the ability to change the text within Premier; preserving the design that you've created in After Effects, but allowing them to, say, make multiple Lower Thirds and change out the name so they don't have to come back to you for those graphics. Well, let's start there. Under the Essential Graphics panel, we need to first set the Master composition, so select that drop down and go to whichever comp you want to use. Let's say this one that says "Lower Third 2", and then we get some controls. It automatically brought in what it thinks that I might want, which were two text layers. Sure enough, that is exactly what I wanted, but if the Essential Graphics panel ever brings in something that you didn't want, just select it and press the "Delete" key. All right. Now that I've done that, I need to bring it back in, so let's grab "Line 2". We have to select a specific property, not the entire text layer. If I click and drag this up, you can see that it's not going to bring that in, but if I expand this down, go into the text, and then find the "Source Text" property, this is what I can drag up and bring in here. On this left column, here, is what the name of the control will display as in Premier, so we need to change the "Source Text" to "Line 2". At this point, I can type anything I want into the actual content, and it will update in After Effects, so I could say, "John Doe", click off of it, and it's going to update in After Effects. So if you wanted to, you could even build a global controls, right here in the Essential Graphics panel, and use it directly in After Effects. In fact, if I deselect and just say, Solo Supported Properties, it's going to bring up every single property in your composition that the Essential Graphics panel can actually control. Similarly to the way that we created controls on this null object, the Essential Graphics panel can also manipulate those controls and give you a central place for modifying things across to your project. I'd say that's a smart way of working if you need to control things across multiple comps. If you're just controlling things inside one single comp, then I generally will just create a null object and add my expression controls to it. But let's say you wanted to give that "Offset Amount" control to the editor. I know, in this particular case, you probably wouldn't. You just want to give them the text fields. But let's say that for some reason you did. Well, we tied all of the offset controls for those shape layers to this slider. Now that those are all being driven by this one slider, I can grab that slider and bring it in instead of bringing the offset amount for every one of those shape layers, one by one, into here. That is one thing that Essential Graphics panel can't do. It can't control multiple values with one control unless you tie it with expressions to something like this expression controller that we've set up. But now that it's in here, I can rename it, "Offset Amount", and as I adjust this slider, it's going to reflect inside of the comp viewer. Let's set that back to 20 and take a look at this third column, over here. On this property, a slider control, you can edit the range just like I showed you before in the actual effect controls. But what is this "Edit Properties" on the text controls? Well, let's find out. These are actually really important because you're able to give the editors the ability to enable custom fonts, so they can change the font; you can give them controls for changing the font size, and you can even give them controls for the faux styles, like faux bold, faux italic, things like that. These wouldn't be controls that I'd want to give to an editor when I have a set style guide, but if you're trying to create something that you might want to sell; especially in Adobe Stock, those are actually required of you; you have to give the user the ability to choose the font and the font size; things like that. So this is where you would go to do it. Just to understand that that makes your templates much more complicated because it gives the template much more opportunity to not work how you intended it to. Anyway, I'm going to leave all of those unchecked and click okay, and these three controls are all I really need to give to my editor. Before I finish this off, I first want to name it, and I'll call this, "Skillshare L3", for a lower third, and I'm going to click the "Set Poster Time", which gives us a screenshot, basically, of our template, which will be visible in Premier. Why don't we just change this from "Motion Designer" to "Title"? This is a placeholder text. We've got "John Doe" and "Title" for Line 1 and Line 2, Set poster Time, and now we can export the motion graphics template. This is saying the project needs to be saved first. Do you want to save it? Yes, I want to save it. Then, it brings up the export window. You can put this wherever you want. If I put it in the "Local Templates Folder", it's going to automatically show up in Premier, so that's where I'll leave it. Then, we have these compatibility checkbox that let us know things like if we're using fonts that are outside of Adobe Fonts library, if After Effects needs to be installed to be able to modify it, or if there are certain controls that I'm using in the Essential Graphics panel that they can't be edited with the Premier Pro "Type" tool. Again, this probably doesn't matter if you're working in an internal team, but if you're sending this template out to the internet, and you need it to be super compatible and flexible, then you're going to want these warnings. You can also add keywords to your templates. Again, this is more for if you're trying to sell them so that they're more searchable. But let's just leave all that blank. Click "OK", and it's going to just export. Now, we can go into Premier and give it a test drive. All right. Here we are in Premier. I started a new project, and let's find that template. I'm going to go up to the "Window", "Essential Graphics" panel. That opens up over here. I need to find my templates, so I'm going to click on that and then scroll down this list. Actually, there's a whole lot here, so let's just search for "skillshare". There we go. That brings it up. I need a timeline to put that in, so let's make a new timeline. We need to make this 1920 by 1080 at 30 frames per seconds, so let's just do "Custom", "30 frames/second", "1920", "1080", "Square Pixels", and click "OK". Here's our sequence, and I'm going to drag that directly into the timeline. That'll take a little bit to load. It's got to read After Effects to help render this out. Now, if we look at our "Program" monitor and play this back, there's our template. In this "Essential Graphics" panel, I have this tab called "Edit". If I go to that tab, and I have my template selected, here are the controls that we assigned in After Effects. Line 1, in a text field, Line 2, in another text field, and then the offset amount. I can change this back to my name, and it's going to update right inside of Premier without needing to go to After Effects for anything. I going to just scale this over so we can see it. Sure enough, it looks exactly the same that it did inside of After Effects. I can play it back, and depending on your machine and how complex your template is, it might not play back in real-time. But this is actually doing a pretty good job. I also have this "Offset Amount" control so I can adjust that if I want to, but that's is showing you that it's possible. Again, I wouldn't really want to give that control to the editor. The point is I've now tested my template, and it's working, so I can share this with my team, and they can start making their own Lower Thirds. One thing I do want to point out is that the length of this is the same as the length of your comp inside of After Effects. I had my comp set to 30 seconds. This way, the editor can just trim it off to wherever they want it to end. Because it's very likely that a Lower Third would ever be 30 seconds long, that should be more than enough time than they'll ever need. But now I can share this working template. That's really all there is to making a motion graphics template. It's not that complex, but my template was not complex, and I didn't give the editor many controls at all, just the two text fields and that offset control, which again, I probably wouldn't ever give to them in the real world if I needed that template to look exactly how I designed it. But there's a very good chance that you might need to make a template that is much more customizable; especially if you're going to try and sell it. Like the templates that I've made on Adobe Stock have lots and lots of controls. In fact, here is what one of my templates looks like. You can see all the controls I built into it. I give controls over the colors, and the font, and transparencies, whether something is visible or not. You can see that it gets a lot more complex the more customizable it needs to be. Obviously, I did not teach you everything that you need to know to make a template that complex. If I did, this class would have probably been eight hours long, so this is really just the first stepping stone into getting into motion graphics templates. If you want to learn more, definitely let me know, and maybe I can make a few more classes like this one. But for your class project, just focus on this Lower Third. Make it as customizable as you want. If you want to add in a lot more of those controls, just hit "Solo Supported Properties". Remember that button in the Essential Graphics panel, and that will show you everything that you could control with your template, and you could just drag in the properties that you want to be able to customize inside of Premier. It's totally up to you how much control you want to give over to the user inside of Premier, but I'm going to let you make that call and getting there, and start customizing things and get this template working the way that you want so that you can test it out on Premier, and make sure everything looks exactly how you want it to.
9. Thanks!: That's the end of this class. Thank you so much for watching and congratulations on making it through the whole thing. I'm really excited to see all the templates starting to come in on the Class Project page. You can always ask me questions if you're running into trouble. I know that expressions are complicated and you can be really stumped on how to get something to work when you're just getting into expressions. I'm here to answer your questions, don't be afraid to ask. If you liked this class, I would love it if you let me review or if you didn't like this class, let me know what I could do better, so that I can improve my future classes. You can follow me anywhere online at Jake In Motion and be sure to hit that "Subscribe" button here on Skillshare, so that you know when I post new content. Thank you again so much for watching and I'll see you in the next one.