5: After Effects Expressions for Beginners: Erros - How to Find and Fix Them
Every project with after effects expressions throws an error eventually. Usually right before a deadline, usually in a comp you haven't opened in weeks. The good news: After Effects has gotten much better at telling you what's wrong. The less good news: the most common causes aren't typos. They're renamed layers, precomps and language versions.
What a broken expression looks like
When an expression can't be evaluated, a warning banner appears at the bottom of the Composition and Layer panels. It stays there until the expression is fixed or disabled.
The banner has three controls:
Left/right arrows step through the errors when more than one expression is failing.
The magnifying glass reveals the broken property in the Timeline. If it's in another comp, After Effects opens that comp for you.
The up/down arrows show or hide the error text.
The error text is a single line and gets cut off to fit the panel, so on a laptop screen you'll often get half a sentence.
What happens to the broken expression itself? Adobe's help page says After Effects does not disable it and keeps evaluating it. A few paragraphs further down, the same page says it disables it automatically. Very helpful. In practice, just look at the = switch on the property. If it's crossed out, the expression is off.
Read the full error message
Next to the broken expression in the Timeline, there's a small yellow warning triangle. Click it and you get the complete error in a dialog, not the truncated banner version. Always read this one. It usually tells you which line failed and what it couldn't find.
Find every broken expression at once
Select one or more layers, right-click (Windows) or Control-click (macOS) in the Timeline, and choose Reveal > Reveal Expression Errors. Only the properties with failing expressions stay visible. On a template with 40 layers, that saves a lot of twirling.
Can you hide the warning banner?
Yes. In the preferences under Scripting & Expressions, uncheck Show Warning Banner when project contains expression errors. New errors won't bring the banner back until you check the box again.
I wouldn't. The banner is annoying precisely because it's useful. If there's an error you've decided to live with, disable that one expression rather than muting every future warning.
Why After Effects expressions break: the usual suspects
1. Something got renamed
Expressions reference layers, effects and property groups by name. When you rename something, After Effects tries to update every expression that uses the old name. It gets most cases right. In more complex setups it can't, and the expression fails because it's looking for something that no longer exists. The fix is to update the name in the expression by hand, or simply pick whip it again.
2. You precomposed
Precomposing moves layers into a new comp. Any expression in the outer comp that still points at thisComp.layer("Logo") is now looking for a layer that isn't there. Adobe specifically warns about expressions that use thisComp instead of a comp name, because thisComp quietly changes meaning depending on where the expression lives. Point the expression at the layer in its new home instead:
comp("Logo Precomp").layer("Logo").transform.position3. The project opens in a different language
This one is sneaky, and it matters to anyone who shares templates. Expressions that rely on display names break when After Effects runs in another language. An expression written in English that references effect("Slider Control") fails in the German version, where that effect is called "Einstellungen für Schieberegler".
Controls you renamed yourself are safe. A slider you called "Bar Spacing" is "Bar Spacing" in every language. It's the default names that change.
Three ways to protect yourself:
Keep the pick whip's Compact English preference switched on (see Part 3).
Always rename your Expression Controls (see Part 4).
Ugly, but it works everywhere.
4. Effect parameters referenced by number
Some effects have changed their parameters between After Effects versions. If an older expression refers to a parameter by its index, like effect("Glow")(3), that number may now point at something else. Adobe recommends referencing parameters by name instead.
5. The wrong expression engine
Current versions of After Effects use a JavaScript expression engine by default. Older projects, and plenty of snippets you'll find on forums, were written for the Legacy ExtendScript engine, and a few things behave differently. You can check and switch under File > Project Settings > Expressions.
The differences you're most likely to hit:
Using this as a shorthand for the layer, as in this("Transform"), doesn't work in the JavaScript engine. Use thisLayer instead.
An expression that ends on an if statement without an else can fail where it used to work. Write out both branches.
My take: stay on JavaScript. It's faster, and it's what current documentation and templates assume. Switch to Legacy only to rescue an old project, fix the expressions, then switch back.
A simple debugging routine
When the error message doesn't make the cause obvious:
Toggle the = switch to confirm the expression is really the problem.
Shrink it. Replace the last line with a variable from earlier in the expression. If that evaluates fine, the problem is further down.
Print values on screen. Create a throwaway text layer and add this to its Source Text:
thisComp.layer("CONTROLS").effect("Bar Spacing")("Slider").valueNow you can see what your expression is actually receiving, frame by frame, instead of guessing.
Check names character by character. Trailing spaces in layer names have cost me more time than I'd like to admit.
That's the series
Five parts, and you now have what you need to build real rigs: add expressions, stack them on keyframes, link properties, wire up controls, and fix things when they break. None of it requires being a developer. Mostly it requires naming your layers properly.
If you want to see these patterns in a finished product, the chart templates in our shop are built on exactly this setup: a controller null, index-based expressions and renamed controls.