The
index
expression in After Effects is used to identify the layer's position in the composition. It returns the layer number, which is useful for creating procedural animations or organizing complex setups.
🎯 What Is index
?
The index
expression gives the layer's number in the timeline stack. For example, the top layer has index = 1
, the second layer index = 2
, and so on.
index
📘 When To Use It?
-
To differentiate layer positions
-
To automate delays between layers
-
To customize properties like opacity, scale, position, etc., based on layer order
🛠️ Practical Examples
1️⃣ Staggered Animation Using Index
delay = index * 0.2;
valueAtTime(time - delay)
✅ This creates a delay between each layer based on its index. Good for cascading animations!
2️⃣ Opacity Based on Index
100 - index * 10
✅ This reduces the opacity for each layer further down the stack.
3️⃣ Position Offset Using Index
x = 100;
y = 100 + index * 50;
[x, y]
✅ Stacks layers vertically with a 50px gap based on their index.
🧪 Pro Tip: Use With thisComp.layer()
for Smart Effects
thisComp.layer(index - 1).transform.position
👉 Gets the position of the layer just above the current one.
📝 Notes:
-
Index is read-only.
-
Changing a layer's order affects the
index
value. -
Helpful in expressions where you want different results per layer.
🧠 Final Thought:
The index
expression may seem simple, but it becomes powerful when used in loops, delays, or smart rigs. It's a must-know for any After Effects expression user!