Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Adding parent to scale expression?

  • Adding parent to scale expression?

    Posted by Ben Christie on December 9, 2015 at 11:49 pm

    Hey guys,

    Sorry I have been having lots of questions as of late!

    So I’m using the following expression to change the scale of a layer based on a background gradient (from black to white) but I also need to have that layer parented to a null that is controlling a lot of layers at once for position.

    The expression works great until I parent the layer to a null and then the layer scales to 0 immediately.

    Is there a way to include the parent in the following expression so it works properly?

    Thanks!

    sourceLayer = thisComp.layer("gradient_ramp");

    sampleSize = [1,1];

    samplePoint = transform.position;

    colour = sourceLayer.sampleImage(sampleSize,samplePoint);

    x=colour[0]*66;

    [x,x]

    Ben Christie replied 10 years, 5 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    December 10, 2015 at 12:34 am

    If everything is 2D, this should work:

    sourceLayer = thisComp.layer(“gradient_ramp”);
    sampleSize = [1,1];
    samplePoint = sourceLayer.fromComp(toComp(anchorPoint));
    colour = sourceLayer.sampleImage(samplePoint,sampleSize);
    x=colour[0]*66;
    [x,x]

    Dan

  • Ben Christie

    December 10, 2015 at 12:47 am

    This worked perfectly. Thanks a ton!

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