Forums › Adobe After Effects Expressions › Index of thiscomp
Index of thiscomp
Gabriel Silva
March 4, 2020 at 10:42 pmFolks. I have A precomp A, and within that precomp A I have a pre-comp B, within composition B I want a text.
I would like the text to follow the precomp B Index.Can you help me I’m desperate!
Sorry for google translator!Dan Ebberts
March 4, 2020 at 10:53 pmWhat do you mean by pre-comp B index? Do you mean the layer index of the pre-comp B layer within precomp A? Something like this:
comp(“precomp A”).layer(thisComp.name).index
Dan
Alex Printz
March 5, 2020 at 3:11 pmCompositions in and of themselves do not have indexes; they are entirely object orientated based on their name. They only get layer indexes when they are precomps inside another comp.
Dan’s solution seems right, but if you are looking for the inverse of that where Comp B is inside Comp A and has a specific index, you could do the code below.
The strength in this method is you can swap out the compB’s with many different precomps all with different text layers inside each, and your compA will update it’s expression.
i = 3; //comp B's exact layer index inside compA;
comp(thisComp.layer(i).name).layer("text layer 1").text.sourceText;
Alex Printz
Mograph DesignerGabriel Silva
March 10, 2020 at 3:26 pmOMG Thanks!! It helped me a lot! You are awesome!
Log in to reply.