After Effect Index expression


It’s taken me a while to understand how this expression works, and putting it into layman terms. The best way I can describe using the index, is imagining the file as a book. Each layer is a page. And when you mark a layer as the index. That layer becomes the bookmark.

But where is the index Number?

You can find the Index Number, of each layer in After Effects next to the Layer name on the left.

Let’s Make a Y-Axis offset using the index.

  1. First make a null layer. This will be the control layer of the movement. We will name this Controller.
  2. Then a new shape layer, using the eclipse tool, and call it "Main_Shape" . Make the fill of this circle black.
  3. Copy and paste the “Main_Shape” layer and rename it "Circle" put it below the “Main_Shape” layer. Change the fill to be purple.
  4. Open the Position Property of the Circle layer by hitting the keyboard short-cut “P” and click on the stop watch.

The letter i is the variable and it holds the information of (“Main_Shape”) as the index by adding the .index to it. Then we are subtracting it by the index of the current layer with the expression - index and the value becomes 1 for i in the Circle Layer. In the second layer below the “Main_Shape” the value for i will be 2.

For the second line of code create a variable call it offSet= . And then take the pick whip tool and link it to the slider expression from the null object.

Note: If you can’t see the slider from the Controller layer. Click on the Controller layer and lock the effects panel by clicking on the lock.

For the last line of code. We need to add the position properties arguments X-Axis and Y-Axis. The default code would be [value[0], value[1] ].

Now the Y-axis value is linked to the slider and index Y-position values. Add key frames on the Slider and playback animation.

Notice, as the slider value increases, so does the second value on the layer of “Circle” in the Y-position.


  • To move up on the Y-Axis change the subtraction sign to a plus sign.
    • [value [0], value [1] + Offset * i ]
  • To move to the Right on the X-Axis change the “- Offset * i” apply it to the first value [0]
    • [value [0] - Offset * i , value [1] ]
  • And if you want the object to move left Left X-Axis , change the subtraction sign to a plus sign before the Offset variable.
    • [value [0] + Offset * i , value [1] ]