setting / animating properties on multiple layers via an expression and for loop
Hello!
I'm working on a comp with dozens of layers / copies of a given precomp and I'm wondering whether it's possible to animate properties on these many layers via an expression and a for loop. Ideally, I would like to put the expression with the loop on a null object on a single layer that would then reference all of the copies. I imagine this might work with an array of layer references?
So far, I have only found a way to acheive the affect without a loop. I can copy-paste the expression on each individual layer, but this becomes tedious from a workflow / iteration standpoint. If I want to edit or change the expression, I need to copy-paste the new expression into layer one-by-one, which is not ideal.
Is it possible to set properties on a layer from another layer, without needing to have the expression on the actual layer?
Here is my expression that I would like to run through a loop. Currently it's on each individual layer's Time Remap property:
// get the offset value from the ctl layer
$offset = thisComp.layer("Ctl").effect("TimeOffset")("Slider");
// define the layer to sample from
$sampleTarget = thisComp.layer("Gradient");
// sample the R channel from the layer
$sampleVal = $sampleTarget.sampleImage(transform.position, [0.5,0.5], true, time)[0];
// do math to set current frame
$customTime = time + ($offset * $sampleVal);
// set the current frame
[$customTime]
Here is a screen recording of my comp where I explain how the layers work.
Thanks!
