Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Simple script for Layer 2’s anchor point relative to Layer 1’s scale.

  • Simple script for Layer 2’s anchor point relative to Layer 1’s scale.

    Posted by Jon Wooley on January 15, 2015 at 10:00 pm

    Hello everyone,

    I’m stumped over what I think should be a relatively simple expression.

    What I’m needing is an expression that pulls a box up as the (text) layer above it gets smaller. The intended effect is for the box to continue to touch the bottom of the text layer no matter what the scale of the text layer is.

    As of right now, I have the two layers (a text layer and a solid with a masked rectangle sitting directly below the text layer) both with their anchor point at the same coordinates in the comp (at the top left of the text layer). When I lower the scale value of the top (text) layer, it, as expected, gets smaller and moves towards it’s anchor point. I’ve been messing around with a number of expressions for the y value of the solid layer’s anchor point so that it moves vertically at the same rate that the text layer is shrinking (and/or growing). Nothing I’ve tried has given me the desired result.

    I’m sure it’s easy but the math keeps eluding me.

    Jon Wooley replied 11 years, 3 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    January 16, 2015 at 4:53 am

    Here’s what I would try. Leave the text layer’s anchor point where you have it, but move the solid layer’s anchor point to the top of its visible area. Position the solid under the text layer while the text layer’s scale is 100%, then apply this to the solid’s position property:

    L = thisComp.layer(“text layer”);
    p1 = L.toComp(L.anchorPoint);
    p2 = toComp(anchorPoint);
    delta = (p2[1]-p1[1])*(100-L.scale[1])/100;
    value – [0,delta]

    Dan

  • Jon Wooley

    January 28, 2015 at 6:14 pm

    Dan,

    Thank you again for your wisdom. The script worked perfectly.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy