Basic Expression Questions
Most common questions about after effects expressions
Basic Expression Questions
What are expressions in After Effects?
Expressions in After Effects are short scripts, written in JavaScript, that allow users to control and automate properties like position, rotation, and scale without manually creating keyframes. This makes it easier to create dynamic effects, especially when animating multiple elements or complex movements.
What language is After Effects expressions?
After Effects uses JavaScript for its expressions, enabling precise animation control. This coding language allows users to automate effects and link properties across layers, making it versatile for complex animation setups.
What is an expression error in After Effects?
An expression error occurs when After Effects can't interpret the script due to syntax issues, unsupported functions, or missing variables. These errors prevent the expression from running and appear as red text in the timeline, prompting users to troubleshoot the code.
Adding & Opening Expressions
How to add an expression in After Effects?
To add an expression, select a layer property, hold the Alt
key (Option
on Mac), and click the stopwatch icon next to the property. This opens the expression editor, where you can input JavaScript code.
How to open expressions in After Effects shortcut?
Use the shortcut Alt + Click
(Option + Click
on Mac) on any property's stopwatch to quickly access the expression editor.
How to enable expressions in After Effects?
Expressions are enabled automatically. To activate one, select a property, Alt-click
(Option-click
on Mac) the stopwatch, and type your script into the editor. Once added, the expression will stay active until removed.
Using & Writing Expressions
How to use expressions in After Effects?
Choose a property (like opacity or scale), Alt-click
(Option-click
on Mac) its stopwatch icon, and enter the desired JavaScript code.
How to write expressions in After Effects?
Open the editor and type in your expression. For example:
wiggle(2, 30);
This adds random motion with a frequency of 2 and amplitude of 30.
How to edit expressions in After Effects?
Click on the expression text in the timeline to open it in the editor. Adjust the code and press Enter
to apply the changes.
How to type expressions in After Effects?
Open the expression editor and type your code. Example:
time * 100;
This scales an element continuously over time.
How to keyframe expressions in After Effects?
You can keyframe a property and then use expressions to repeat or modify them. Example:
loopOut("cycle");
This loops the keyframes in a continuous cycle.
How to access expressions in After Effects?
Select a property and Alt-click
(Option-click
on Mac) its stopwatch. This opens the editor where you can add or adjust expressions.
Specific Expression Types
How to use wiggle expression in After Effects?
The wiggle()
function adds random movement to a property.
wiggle(frequency, amplitude)
Example: random motion 3 times per second with a 30-unit range.
wiggle(3, 30)
You can apply this to Position, Rotation, Scale, etc.
How to loop a wiggle expression in After Effects?
To create a perfectly looping wiggle, use this expression. It blends between two wiggle samples (start and end of the loop) so the motion resets smoothly:
// How fast the wiggle moves (per second)
wigglesPerSecond = 2;
// How much the property moves (in pixels, degrees, etc.)
wiggleAmount = 40;
// Loop length (in seconds)
loopTime = 3;
// Time within the loop (wraps around every 'loopTime' seconds)
current = time % loopTime;
// Sample two wiggles: one at current time, one a full loop earlier
start = wiggle(wigglesPerSecond, wiggleAmount, 1, 0.5, current);
end = wiggle(wigglesPerSecond, wiggleAmount, 1, 0.5, current - loopTime);
// Blend between the two wiggle states for a perfect loop
linear(current, 0, loopTime, start, end);
How to use posterize time expression in After Effects?
posterizeTime(12);
This slows down how often an expression updates (in frames per second). You can combine it with wiggle for a choppy effect:
posterizeTime(8);
wiggle(2, 50);
Great for stop-motion or stylized animation.
How to stop wiggle expression in After Effects?
Use if
with time
to stop wiggle after a certain point:
if (time > 3){
value;
} else {
wiggle(2, 30);
}
This applies wiggle until 3 seconds, then keeps the value steady.
To stop wiggle using a checkbox:
Add a Checkbox Control to your layer.
Rename it to
"Stop Wiggle"
(or anything).Use this code:
var stop = effect("Stop Wiggle")("Checkbox");
if (stop == 1){
value;
} else {
wiggle(2, 30);
}
When the checkbox is checked, the wiggle stops.
How to add loop expression in After Effects?
loopOut()
repeats keyframed animations, not expressions.
Basic example:
loopOut("cycle")
Loop types:
"cycle"
– loops from start to end"pingpong"
– plays forward, then backward"offset"
– repeats with motion offset"continue"
– continues with same speed/direction
Example:
loopOut("pingpong")
How to stop loop expression in After Effects?
There’s no direct way to stop a loopOut()
using a condition. But you can:
Split the layer where you want the loop to stop
Add a new keyframe after the loop range to end the cycle
Use an expression to override the value, but this requires more complex logic and is often better solved with baked keyframes
Expression Management & Troubleshooting
How to fix expression errors in After Effects?
Check the syntax, make sure all variables are defined, and confirm you're using supported JavaScript functions. Errors are shown in red in the timeline.
How to show expressions in After Effects?
Expand the layer's properties. If an expression is active, you’ll see the code line with an arrow. Click it to view or edit.
How to copy expressions in After Effects?
Right-click the property with the expression and choose Copy Expression Only. Then paste it onto another property.
How to remove expression in After Effects?
Alt-click
(Option-click
on Mac) the stopwatch again to delete the expression.
How to save expressions in After Effects?
Save the property as an animation preset via Animation > Save Animation Preset, or copy and paste the code externally for reuse.