Adobe After Effects Expressions and Scripting 2 — Questions and Answers
Question 1: What does the `valueAtTime(t)` method do in an After Effects expression?
- Returns the value of the property at a specified time `t` in seconds (Correct answer)
- Sets the property value at time `t` to a keyframe
- Returns the animation speed of the property at time `t`
- Converts the time `t` from frames to seconds
Correct answer: Returns the value of the property at a specified time `t` in seconds
valueAtTime(t) samples a property's value at any given time, enabling delay effects, echo trails, and time-offset animations.
Question 2: What does `effect("Slider Control")("Slider")` do in an After Effects expression?
- References the value of a Slider Control effect applied to the current or target layer (Correct answer)
- Applies a Slider Control effect to the layer automatically
- Returns the slider position in the user interface
- Reads a property from the Effect Controls panel
Correct answer: References the value of a Slider Control effect applied to the current or target layer
This expression retrieves the current value of a Slider Control effect, letting you drive multiple properties from a single master slider.
Question 3: What does `Math.sin(time * frequency) * amplitude` create when applied to a Position expression?
- A smooth sinusoidal oscillating motion at the given frequency and amplitude (Correct answer)
- A random erratic position change with sine-shaped noise
- A spiral motion path along the X axis
- A bounce effect that decelerates over time
Correct answer: A smooth sinusoidal oscillating motion at the given frequency and amplitude
Math.sin creates a smooth, predictable periodic oscillation — useful for pendulum swings, looping wave motion, or pulsing effects.
Question 4: What does the `index` expression variable return in After Effects?
- The layer's order number (index) within the composition's layer stack (Correct answer)
- The index of the current keyframe on the property
- The frame index of the current time position
- The index of the expression within the layer's expression list
Correct answer: The layer's order number (index) within the composition's layer stack
The `index` variable returns the layer's position in the layer stack (1-based), enabling offset animations that increment per layer.
Question 5: What does `toComp()` method do in After Effects expressions?
- Converts a point from a layer's local coordinate space to the composition's coordinate space (Correct answer)
- Sends the current layer to the main composition
- Converts an effect parameter value to a composition-level unit
- Renders the current composition to a file
Correct answer: Converts a point from a layer's local coordinate space to the composition's coordinate space
toComp(point) transforms a 2D or 3D point from the layer's local space into the composition's global coordinate system.
Question 6: What is the purpose of `try { } catch(err) { }` in After Effects expressions?
- Prevents the expression from throwing a red error and allows fallback behavior when an error occurs (Correct answer)
- Catches keyframe timing errors during playback
- Handles null pointer errors in the render queue
- Intercepts user input errors in scripts
Correct answer: Prevents the expression from throwing a red error and allows fallback behavior when an error occurs
Wrapping expression code in try/catch prevents the red error state and lets you provide a default fallback value if the expression fails.
What does the `valueAtTime(t)` method do in an After Effects expression?