Viewers: in countries Watching now:
Expressions are one of the most powerful but underused features in After Effects. They can be used to animate layer properties with code, as compared to explicitly keyframing every value in the Timeline, and have multiple parameters and layers that follow the lead of a master layer or controller effect, making it much easier to coordinate complex animations and quickly accommodate client changes. In this introduction, Chris Meyer shows how to let After Effects do most of the work by creating simple but very useful expressions that can be put to work on a wide variety of jobs.
The After Effects Apprentice videos on lynda.com were created by Trish and Chris Meyer and are designed to be used on their own and as a companion to their book After Effects Apprentice. We are honored to host these tutorials in the lynda.com Online Training Library®.
In this chapter, we're going to take your expression skills to the next level by going just a little bit further in what you can do with the Pick Whip tool and simple numbers. If you've watched the last movie in this series, we're continuing on with the Clockwork copy I've been working with. If you jump straight here, just go ahead and open up the comp 03-Clockwork*starter in the project AEA_expressions. Don't worry about having not expressed the hour and second hands yet; we're still tying everything off of what the minute hand is doing. In fact, I'll twirl those up for now. You might have noticed we have this nice blue background going on behind this watch face.
We actually gave you a second background layer as well. If I turn off the Alien Atmospheres movie, you'll see we have this Digidelic movie that we've used in few of our lessons. Let's say that we want to reveal that Digidelic movie with a sweep that's coordinated with that minute hand. Well, there is actually an effect that does that. I've selected Alien Atmospheres, go up to Effect, and go down to the Transition category, which is multiple ways of getting rid of one layer to reveal whatever lies underneath.
In this case, we want a Radial Wipe. Radial Wipe has a parameter called Transition Completion that does this clockwork-type reveal that we want. There is a problem though: whereas rotation works in degrees-- 360 degrees being a full circle--Transition Completion works in percentage with 100% being a full circle. How do we line those two up? Well, we could just use the Pick Whip tool and simple math...
well, not-so-simple math. You'd have to search saying, well, divide by 360 because that's the degrees, times 100 by the completion, that should get us back to where we want to be, and you'd be right. But rather than twisting your mind every time you need to convert one parameter range to another, there's this wonderful little expression called Interpolation that can do it for you. So let's explore that. We want Transition Completion to follow Rotation. I already have rotation exposed. I'll hold on Option or Alt, click on the stopwatch for Transition Completion, and it will be exposed down here in the Timeline panel.
Rather than use the Pick Whip tool or start typing code, I'm going to take advantage of this little arrow here and reveal what's known as the Expression Language menu. For those who are really get into expressions, this is a list of many different expression methods and other arguments that are available to you inside After Effects. The category we're interested in is called Interpolation, how to take one range of numbers and interpolate it to match what you need for a second range of numbers. In this case, we want to use the linear interpolation, so it's a straight-up translation, and we are going to use this second option.
I'll select that and After Effects will write this little starter piece of code for me automatically. What this code is really telling me is it wants to take a value, t--the default is to use time, but it can be anything you want--and as that value goes from its minimum to its maximum value, translate it into a new desired minimum and maximum value. At this point, we can just go ahead and use the Pick Whip and type in numbers, just like we have so far. I'll carefully select this t and say, rather than using time, instead I want you to follow the rotation of this layer.
Let go over the mouse and all the code I need is written for me. I don't need to type this by hand, but it's easy enough to read. This comp has a layer called minute. Use its transform property, rotation. Great! What's rotation's minimum? 0. What its maximum? 360. That's easy. What's the minimum value I want to translate to? 0 for 0% transition completion. What's the maximum value I want to translate to? 100 for 100% complete, literally all there is to it.
Click off, the expression has been accepted, and you're going to already see up here in the Comp panel that this transition is lining up with the minute hand. I'll press 0 in the numeric keypad to RAM preview, and you'll see I now have a coordinated animation. And just as with any other expressions, I can go ahead and edit these keyframe values. Maybe I want it to be a full 360 degrees. Enter, zero to RAM preview, and automatically, my effect for transition completion follows along with my altered master keyframe value.
This linear expression is one of my favorites. I use it all the time because I'm forever having to translate to get animations to line up. Remember that it resides underneath the Expression Language menu > Interpolation, second one down. Use the Pick Whip to replace the t with whatever property you want to follow and just type in your starting and minimum and maximum, your target minimum and maximum. By the way, if you want to see a finished version of this composition, go back into the Project panel, twirl open Comps_Finished, and open up 03-Clockwork_final.
We've done a lot more things here. We've added drop shadows and in the case of the drop shadows on the watch hands, we use that trick you've already learned earlier in this lesson to make the shadow always follow the right direction. We're doing the Radial Wipe and we're doing one more trick that's kind of fun: we're having the hue of that background layer change as the animation progresses, and we're using the exact same trick we used for Radial Wipe. I'll select the Alien Atmospheres layer. Press F3 to reveal it in the Effect Controls panel.
You'll see I use the effect Color Balance. It has a Hue value that also goes from 0 to 360 degrees. But I didn't want it to go all the way around the Hue wheel. I want a very specific range. So what I did is, with the expression turned off, and set somewhere where I can see what I was doing, I went ahead and scrubbed the Hue value to see what I wanted for a starting color, maybe something in there to go ahead and match my watch face color. Then went towards the end of the animation where I can see just a little segment in here and scrub and say, let's go ahead and match the color of my new background as we get close. Maybe something more in that range.
And once I know what those two values are, I just went ahead and use that same linear expression. I used the pick whip to tie it to the rotation of the minute hand, and as it went from the 0 to 360 degrees, I said I wanted my Hue rotation to go from -180 to 120. Just the same thing as we just did with Transition Completion. I'll click off, the expression turns back on, RAM preview, return to the start of my comp, and as I drag the Current Time Indicator through here, you can watch how the Hue value changes to coordinate its movements with the minute hand.
So the Linear Interpolation expression is one good tool to have in your toolkit. Another one is the Loop expression and I'll show that in the next movie.
Find answers to the most frequently asked questions about After Effects Apprentice 09: Expressions .
Here are the FAQs that matched your search "" :
Sorry, there are no matches for your search "" —to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.