Adobe After Effects Expressions Forum
Access Time property of a child composition
Access Time property of a child composition
by Shin Huynh on Apr 16, 2019 at 10:18:19 am

i would like to change the position of a composition A every time the time in composition B hit 1s , 2s , 3s ,...
A and B are in the same composition ,
how to access the time of the B comp ; sorry i'm very new to expression , i tried
thisComp.layer("B").time
but it did not work
please , help me

thisComp.layer("B").time



Re: Access Time property of a child composition
by Kalleheikki Kannisto on Apr 16, 2019 at 3:10:40 pm

This should give you the basic idea for moving layer B after layer A starts. Position expression for layer "B" :

A = thisComp.layer("A")
myTime = A.time-A.inPoint;
myPlaceX = 1000+Math.max(100*Math.floor(myTime),0);
myPlaceY = 500+Math.max(50*Math.floor(myTime),0);
[myPlaceX, myPlaceY]


Math.max is used to ensure we start at 0, not in the negative range.
Math.floor is used to move only at full seconds.
inPoint is the time at which the layer starts.

Layers A and B are in the same level of hierarchy here, though. Although it doesn't sound like you have it set as a child comp, if you did have a comp named "B Comp" within which you have a layer named "B", it would be this way instead:

A = comp("B Comp").layer("B")
myTime = A.time-A.inPoint;
myPlaceX = 1000+Math.max(100*Math.floor(myTime),0);
myPlaceY = 500+Math.max(50*Math.floor(myTime),0);
[myPlaceX, myPlaceY]


(I have the layers "A" and "B" kinda reversed there...)

Kalleheikki Kannisto
Senior Graphic Designer





© CreativeCOW.net