Page 1 of 1

Referencing Layers within Precomps

Posted: March 6th, 2008, 3:48 pm
by ahettinger
Hi,

I'm using this expression on the scale of some precomps based on the closeness of another layer. But I also need it to change the opacity of a layer inside the precomps. All the precomps are set up the same way, with same amount of layers in the same order. What is the best way to go about referencing the layer? It would be best if I could do it by layer number.


startS = 200; //start scale 400 pixels from null
endS = 50; //end scale 50 pixels from null
C = thisComp.layer("Proximity").toWorld([0,0,0]);
P = toWorld(anchorPoint);
d = length(C,P);
linear(d,startS,endS,[125,125],[100,100])


Thanks in advance!

Re: Referencing Layers within Precomps

Posted: March 7th, 2008, 9:13 am
by lloydalvarez
This should work for opacity. I also changed it so that it references the layer by layer number.

-Lloyd

Code: Select all

startS = 200; //start distance (in pixels) from null
endS = 50; //end distance from null
startO= 20; //starting opacity
endO= 100; //ending opacity
C = thisComp.layer(1).toWorld([0,0,0]);
P = toWorld(anchorPoint);
d = length(C,P);
linear(d,startS,endS,startO,endO)

Re: Referencing Layers within Precomps

Posted: March 7th, 2008, 10:27 am
by ahettinger
Thanks, this actually works backwards from the way I thought it would (I was thinking apply it to the , but makes more sense this way too. Here's the final script I'm using:

startD = 200; //start distance (in pixels) from null
endD = 50; //end distance from null
startO= 100; //starting opacity
endO= 50; //ending opacity
C = comp("Comp Name").layer("Layer Name").toWorld([0,0,0]); //proximity layer
P = toWorld(anchorPoint);
d = length(C,P);
linear(d,startD,endD,startO,endO)

I had another question, what if I wanted to "ease" the movement, (like for the scale property) so that the movement isn't so linear? Is there a way to move the scale along a sine curve or something?

Re: Referencing Layers within Precomps

Posted: March 7th, 2008, 10:33 am
by lloydalvarez
you can replace the word linear with ease to ease both your in and out like this:

Code: Select all

startS = 200; //start scale 400 pixels from null
endS = 50; //end scale 50 pixels from null
C = thisComp.layer("Proximity").toWorld([0,0,0]);
P = toWorld(anchorPoint);
d = length(C,P);
ease(d,startS,endS,[125,125],[100,100])
If you only want to ease the In, then use easeIn or easeOut for the out..

-Lloyd

Re: Referencing Layers within Precomps

Posted: March 7th, 2008, 10:54 am
by ahettinger
Awesome, thanks for all the help!