1 person found this helpful
In your main comp, create a null layer. Name it Opacity control. Apply Effect>Expression Controls>Slider to it.
In your shapes comp alt-click (or option-click on a Mac) the opacity property of your inner rectangle. Write the following expression:
comp("Main comp").layer("Opacity control").effect("Slider Control")("Slider");
Then in your main comp you can control the opacity by moving the slider on the null object.
Or, rather than writing the code and making sure all of your capitalization and spelling of the layers is correct, just drag the timeline of your precomp out separate from your other comp's timeline and pickwhip from the opacity on the rectangle layer to the slider effect on the null.
Partial success. When I set the slider to 0 the outer rectangle disappears completely and the when I set it to 1 its opacity (in the main comp) in 100%, although in the shapes comp the opacity tracks the slider accuratly and sets the opacity correctly. I've tried going into decimals on the slider but it has a sharp cut off point where the rectangle is either on or off.
Where do you apply the expression? On the opacity parameter of the entire shape layer or inside a shape blending group? Do you use specific blending modes that may just make it appear as if it where using incorrect ranges because the layer content appears instantanuously rather than gradually based on the underlying formula?
This approach is actually not addressing my original need. What I'm hoping to be able to do is take an object oriented programming approach. I'd like to be able to create an object (the 'shape comp') which I can drop into many other comps but be able to make adjustments to the properties of a shape comp from the comp within which it is nested. The changes to any one shape comp must not effect any of the other nested shape comps.
Is this possible?
1 person found this helpful
Not if multiple copies of the precomp are on the screen at the same time.
And only if the parts of the precomposition that are used are from different points in the precomposition's time.
So, you would want to make your precomp the same size, or longer than the amount of time it will be used so that no one instance is from the same point on the precomp's timeline.
I think the basic answer to your question is no..
The answer is no. A comp has no way of knowing what comp it is nested in.
Also, in your original post it looks like you were trying to set the value of the opacity property of the layer from an expression on another property (on another layer in another comp). In expressions, only user-defined variables can be written to. Everything else, including the values of layer properties, is read-only. The only way you can modify the value of a property is by applying an expression to that property, and you don't modify the value through an assignment statement (e.g. "opacity = 50"), but rather by writing the last statement of the expression such that it evaluates to the desired value (e.g. "50"). That's the "expression" part of expressions.
Thanks guys. I know what to put on my wish list.