Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Control layer size-changing expression not working correctly

  • Control layer size-changing expression not working correctly

    Posted by Patrick Perkins on November 6, 2017 at 8:01 pm

    Hello, I’m having some trouble and I’m sure it’s because I’m making some bonehead mistake.

    I have a grid of shapes, and I’d like to control their size using a control layer. I’ve done this before in other files. I want them to be basically at 0% scale when the control layer below them is white, and 100% scale when the control layer behind them is black. I’m kinda basing it off this tutorial video: https://www.youtube.com/watch?v=4OQN2mHQuD0&t=554s

    Here’s a screenshot of the grid of x’s, with the control layer (Pottery.psd) behind it.

    Deeply confused, since this expression has worked perfectly in other files (at least when attached to “rotation” instead of scale), I would love to get someone else’s take on it. I’m not getting error messages, the x’s just aren’t responding in scale to the control layer at all. I don’t know what I’m doing wrong!

    The expression I’m adding to the “Scale” attribute on the x’s is below.

    sourceLayer = thisComp.layer("Pottery.psd");
    sampleSize = [1,1];
    samplePoint = transform.position;
    color = sourceLayer.sampleImage(sampleSize,samplePoint);
    x = color[0]*100;
    [x,x]

    Some contents or functionalities here are not available due to your cookie preferences!

    This happens because the functionality/content marked as “Google Youtube” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.

    Patrick Perkins replied 8 years, 9 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    November 6, 2017 at 8:24 pm

    I think sampleSize and samplePoint should be swapped in sampleImage().

    Dan

  • Patrick Perkins

    November 6, 2017 at 8:59 pm

    Dan, nothing happened when I tried that!

  • Dan Ebberts

    November 6, 2017 at 9:43 pm

    Is anything parented? Is your sample layer not comp-sized? Is it scaled? If so, this might help:

    sourceLayer = thisComp.layer(“Pottery.psd”);
    sampleSize = [1,1];
    samplePoint = sourceLayer.fromComp(toComp(anchorPoint));
    color = sourceLayer.sampleImage(samplePoint,sampleSize);
    x = color[0]*100;
    [x,x]

    Dan

  • Patrick Perkins

    November 6, 2017 at 11:22 pm

    That worked! My control layer WASN’T comp-sized and WAS scaled, I didn’t know that would affect that. Thank you, Dan!! This has been annoying me for days, I appreciate your help!

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