Change layer order with expressions
by MattMariska
on
Feb 15, 2007 at 4:07:37 am
Hello! I'm new to posting to these forums, but I've been reading them for help countless times over the past years.
I'm just a beginner with AE Expressions, and I was wondering if the following is possible:
I would like to change the order (or perceived order) of layers in my composition, based on their Y axis. In this composition, the lower a layer is vertically, the closer it should be to the camera. Therefore, anything lower vertically should overlap anything else higher vertically. Is this possible?
I hope I'm explaining myself well enough. Thank you for taking the time to give me a hand with this.
Re: Change layer order with expressions by Colin Braley on Feb 15, 2007 at 7:24:26 am
Well you can't make the layers become stacked in a different order via expressions, however scripting could sort the layers based on the y position at frame zero, or something like that. However, you could change the z-position of layers based on y position. You could create an expression to do something like place the layer with the largest y value at z = 0, the layer with the second largest y value at z = -100, the layer with the third largest y value at z = -200 etc. Just clarify what you are looking for a bit more and Im sure someone will be able to help you out.
~Colin
Re: Change layer order with expressions by Dan Ebberts on Feb 15, 2007 at 2:30:18 pm
Yeah, I'd make them all 3D and use an expression like this to sort them in Z space:
below = 0;
for (i = 1; i <= thisComp.numLayers; i++){
if (i == index) continue;
if (thisComp.layer(i).position[1] < value[1]) below--;
}
[value[0],value[1],below]