This iExpression is applied to the Focus Distance of an After Effects camera and controls it such that a particular layer always stays in focus. You can also transition the focus from one layer to another one.

If you want to keep one layer in focus all the time, just enter the name of the layer at "Focus Layer 1" and apply the iExpression.

If you want to transition between several layers, enter additional ones at "Focus Layer 2", "Focus Layer 3" and so on.
Then add keyframes to the Focus Distance (you can add keyframes to a property, also if an expression is applied to it) and set it to 1 to get "Focus Layer 1" in focus and so forth. Note that with the keyframes you cannot control "how" to transition from one focus layer to the next one: If you have keyframes "1" and "3" the camera focus directly transitions from layer 1 to layer 3 without focusing on layer 2 inbetween. To make this possible, the expression just considers the keyframe values but not the easing between them.

However, you have full easing control with the "Transition" parameter of the iExpression.

  • Focus Layer 1-30

    name of the layer that should be in focus when you keyframe the focus to the respective value.

  • Transition
    Transition Type

    Determines how to transition from one focus layer to another one, if you keyframe this focus.

    Link Manual Transition

    If the transition type is set to "manual" link here a slider to control the focus transition from the previous to the next layer. Keyframe the slider to start with a value of 0 at the beginning of each transition and a value of 100 at the end of each transition. How to transition from 0 to 100 controls how the focus transition is done exactly.

  • Offset

    Animate this property, if you want to temporarily move the focus away from the focus layer. You can link this to a slider and apply a wiggle to the slider, for example, to simulate some "pumping" auto-focus.

Autofocus on Layers iExpression

can be applied to: 
1D properties
iExpression Bundle: 
Download at

What are iExpressions?

iExpressions are After Effects expressions with an easy to use interface.