Skip to main content
Participant
May 17, 2013
Question

Accessing a layer in a precomp (syntax question)

  • May 17, 2013
  • 1 reply
  • 468 views

I've figured out how to access a layer, by assigning it to a variable.

But when the layer is a precomp, how do I access a layer within that precomp.

What is the basic syntax?

This topic has been closed for replies.

1 reply

Inspiring
May 17, 2013

Let's say your main comp is called "A", and in there you have a precomp "B". Inside "B" you've got a layer called "L" that you want to access.

To do that you need to get "B" as an AVLayer, then get it as a CompItem by using it's source:

var a_comp = app.project.activeItem;

if (a_comp && a_comp instanceof CompItem)

{

    var b_layer = a_comp.layer("B");

    var b_comp = b_layer.source;

    if (b_comp && b_comp instanceof CompItem)

    {

        var l = b_comp.layer("L");

     }

}

I added the checks that a_comp and b_comp exist and are indeed CompItem variables just as an example, you should obviously also check that b_layer isn't null.