- 01
The loop expression takes keyed animation and does something immediately after. It'll either PING PONG, (go back and forth with the animation) CYCLE, (which loops the animation from the beginning over and over again) or CONTINUE (which keeps the value of the animation going in that direction)
loopOut("one of the 3 options"), loopIn("one of the 3 options"), loopInDuration("one of the 3 options"), loopOutDuration("one of the 3 options") commands and their "ping pong", "cycle" and "continue" modes.Personally, I almost always use loopOut("[one of the 3 options]"). What I'll do is key an animation for a property at the start of the timeline, then apply this expression. Easy peasy. I might use loopOut("continue") for linear actions, lets say for a rotation or loopOut("cycle") random animation that I want to keep going forever. I learned a little more about the loop expression today. This blog post really explains this part really well. You can also determine how many keyframes you want to LOOP with the second value of the expression.
loopOut(type="cycle", numKeyframes=0);Shinsuke's animation shows really well what this means. Also, check out the Adobe help page about this expression and more.
NOTE: The original link that this came from seems to be broken. That's too bad because it was a great resource.
- 02
Imagine this scenario. You're working on a project and they want 140 pictures animated similar to the classic Ken Burns style. Each one needs to animate in, the fade out at a set number of frames. SURE you could animate one layer then copy pasta the keyframes to all the layers, but what if you need to modify them? These simple expressions will give you the flexibility to add clean and elegant movement and in/out fades based on the duration of the clip itself. Check these out.
I found a few AMAZING formulas that gave me the freedom to slap in a bunch of layers quickly and get it done quick.
For a consistent fade in and fade out paste THIS in your opacity:
fadeFrames = 20; fadeTime = fadeFrames*thisComp.frameDuration; Math.min( linear(time, inPoint, inPoint + fadeTime, 0, 100), linear(time, outPoint - fadeTime, outPoint, 100, 0) );Then paste THIS into your scale:
startScale = [20,20]; endScale = [100,100]; linear(time, inPoint, outPoint, startScale, endScale);I have used this with great effect! I mostly use the opacity, but the scale works really well too. PRO TIP: Move the anchor point of a layer in after effects to an area that you want to focus on, like a face and the slow scale will center around that point. Now, recently I came across a scenario where I needed custom fade in and out speeds. Mainly, I needed the speed of the start of the fade in to be faster than the out. So after much strain and a long time experimenting and understanding the hieroglyphics that is this expression, I developed a NEW formula for the opacity that allows for separate duration for fade in and fade out. Check it out:
fadeFramesFRONT = 7; fadeFramesBACK = 10; fadeTimeFRONT = fadeFramesFRONT*thisComp.frameDuration; fadeTimeBACK = fadeFramesBACK*thisComp.frameDuration; startFADE = 0 ; endFADE = value ; // putting 'value' here allows you to control the max opacity simply by changing the value. no need to go into the expression. you can put an actual value here too if you want or connect it to a slider somewhere. // instead of linear, I'm using ease, but you could also use easeIn or easeOut Math.min( ease(time, inPoint, inPoint + fadeTimeFRONT, startFADE, endFADE), ease(time, outPoint - fadeTimeBACK, outPoint, endFADE, startFADE) );These formulas, as seemingly trivial as they are, have actually saved SO much time from having to animate dozens sometimes HUNDREDS of layers basically the same but at different places in the timeline. It's a great time saver formula.
- 03
Yet another awesome thing. How to link a 2D point to a 3D point (like a light or a 3D null) and it's hella simple. Find the tutorial I got this from Video Copilot. You know who they are... and if you don't, PLEASE check out their large library of tutorials. 1- Alt + Click the 2D position value 2- Pickwhip the 3D layer then add ".toComp([0,0,0]);"
thisComp.layer("3DLAYERNAMEHERE").toComp([0,0,0]);If you've used After Effects for a small period of time, chances are you have come across the problem of trying to connect a 3D layer position with a 2D effect (like trying to connect the standard lens flare effect to a 3D null or something). Well this helps you solve that! Plot this expression in the 2D point and you're good! I've found, however, that you can modify this expression to connect a 2D point with another 2D point! This works really well when you want something to follow something else (like maybe a puppet pin point to a controller null or something). Simply take out a ",0" and you'll end up with:
thisComp.layer("2DLAYERNAMEHERE").toComp([0,0]);Leave a comment below to let me know how you use this and if it was helpful to you!
- 04
Found HERE, this expression is REALLY useful if you want some random motion or animation, using wiggle, but you also want it to loop at regular intervals (ie: repeat random motion every 3 seconds) This will give you a seamless loop that is amazing.
freq = 1; amp = 110; loopTime = 3; t = time % loopTime; wiggle1 = wiggle(freq, amp, 1, 0.5, t); wiggle2 = wiggle(freq, amp, 1, 0.5, t - loopTime); linear(t, 0, loopTime, wiggle1, wiggle2)He even adds a REALLY helpful guide to what all this means, which is nice.
- 05
If you don't use Animation Composer by Mister Horse to do this, or if you need something very specific, you can use these expressions.
Inertial Bounce is like making your moves "rubbery." Layers will overextend, then settle into place on position and rotation keyframes.
amp = .05; freq = 4.0; decay = 2.0; // Play with these values to get the correct bounce you want n = 0; if (numKeys > 0){ n = nearestKey(time).index; if (key(n).time > time){ n--; } } if (n == 0){ t = 0; }else{ t = time - key(n).time; } if (n > 0){ v = velocityAtTime(key(n).time - thisComp.frameDuration/10); // This is where the AMP FREQ and DECAY were originally value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t); }else{ value; }The values you want to play with are AMP, FREQ, and DECAY. AMP (Amplitude): the larger the number the stronger the bounce. FREQ (Frequency): basically how many bounces you get after the keyframe DECAY: how long it takes for the bounces to die down. I use it in all sorts of things, but this works really well to "fake" simulated dynamics. Contrary to typical fashion, if you use this expression, make the out keyframe linear and hard that way the bounce has some inertia from the motion.
- 06
I make a quick and fun video for Junior Baby Hatter, which required a timer. I've done these before, but this one needed to start and stop at a specific time. After a few minutes of research, I found this youtube video that showed a way of using expressions. Watch it to get a better understanding of how it works. Below is the expression so you don't have to download the file.
countspeed = 1;
clockStart = 0;
function times(n){
if (n < 10) return "0" + n else return "" + n
}
clockTime = clockStart +countspeed*(time - inPoint);
if (clockTime < 0){
minus = "-";
clockTime = -clockTime;
}else{
minus = "";
}
t = Math.floor(clockTime);
h = Math.floor(t/3600);
min = Math.floor((t%3600)/60);
sec = Math.floor(t%60);
ms = clockTime.toFixed(3).substr(-3);
minus + times(h) + ":" + times(min) + ":" + times(sec) + ":" + ms
- 07
THIS NEEDS TO BE UPDATED
If/Else or if/then or some variation of this expression exists in almost every programming language.
I found this at Premium Beat, and every time I forget I go back there. Follow the instructions down below:
if(thisComp.layer(“WhiteShape”).transform.opacity>50) 100 else 50Operator OPTIONS:
< Less Than
> Greater Than
<= Less Than or Equal To
>= Greater Than or Equal To
== Equals To
- 08
FOUND HERE: https://vimeo.com/68484532 and HERE: https://forums.creativecow.net/docs/forums/post.php?forumid=227&postid=9393 Also HERE: http://www.videocopilot.net/forum/viewtopic.php?f=5&t=13552
offset = -.5; //The offset in time, negative half a second. p = thisComp.layer("My Animated Layer"); //The parent layer t = time + offset; //The current time minus half a second p.position.valueAtTime(t); //Value of the parent's position property at the current time minus half a second - 09
Are you the kind of designer that makes templates? This is one useful way to allow templates with color pickers that can be moved around dynamically. First you set variables. The first one is the layer whose center point will be the color picked. Second is the actual layer with the colors that you want to be picked. In my case, COLOR 01 is a shape layer that I designed to look like a color picker. Then using the ".sampleImage()" expression you will write the expression as seen below.
var point = thisComp.layer("COLOR 01").transform.position; var colors = thisComp.layer("COLOR REFS"); colors.sampleImage(point, radius = [.5, .5], postEffect = true, t = time)Using this system you can sorta break it down visually. One thing I want to point out is the radius. That describes the sample size. If the radius is bigger than [.5,.5] it'll start to average out the colors within that radius. You could theoretically have a greater range of colors using that system. Hope that helps!
© 2024 by Alex Velazquez. All rights reserved unless otherwise stated.
This website was custom designed and made by myself using Wix Studio.

Animation resources
I use almost every day
Welcome to my Animation Resources section, where I've compiled an extensive collection of tools and resources that I rely on daily. Whether you're looking for stock images, video clips, or clever After Effects code snippets to streamline your animations, you'll find it here. Many of these resources are my own creations and are available to you completely free of charge. Let these resources inspire your creativity and fuel your animation projects!