Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Link Opacity to Y Position in Comp

  • Link Opacity to Y Position in Comp

    Posted by Skylar Moran on July 15, 2015 at 9:40 pm

    Hello!

    I am pretty new to expression in AE, so forgive my ignorance, but I have been combing the internet for an hour trying to find help to solve this problem and haven’t had any luck. So here it goes.

    I have a very long column of text layers that I am animating to scroll upwards using a null. I need each line of text to fade in at a certain point on the screen, and then to fade out at another point so that only a few lines are visible at a time.

    I’m running into a block because the position is animated entirely by a parent null, and the speed increases to a fast enough pace that doing it manually wasn’t working.

    I found some expressions linking opacity to distance from a 3D camera and I think a modification of that might work in my situation, but I haven’t been able to figure it out.

    I hope one of you geniuses knows what’s up.

    Skylar Moran replied 10 years, 10 months ago 2 Members · 6 Replies
  • 6 Replies
  • Kevin Camp

    July 15, 2015 at 11:12 pm

    try this:

    opacityMin = 0;
    opacityMax = 100;

    fadeInStart = 600;
    fadeInEnd = 500;
    fadeOutStart = 300;
    fadeOutEnd = 200;

    y = toComp(anchorPoint)[1];

    if (y <= fadeOutEnd || y >= fadeInStart){
    opacityMin;
    }else if (y < fadeInStart && y > fadeInEnd){
    linear(y, fadeInEnd, fadeInStart, opacityMax, opacityMin);
    }else if (y < fadeOutStart && y > fadeOutEnd){
    linear(y, fadeOutEnd, fadeOutStart, opacityMin, opacityMax);
    }else{
    opacityMax;
    }

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

  • Kevin Camp

    July 15, 2015 at 11:16 pm

    i should have added that the fade values (fadeInStart, etc) are in pixels. they define the area that the lines will be at maximum opacity, minimum opacity or interpolate (fade) between those values.

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

  • Skylar Moran

    July 15, 2015 at 11:24 pm

    Ok wow great this sounds like exactly what I need. Will it still work even though the position of the actual text layer isn’t changing, just the position of the null it’s parented to is?

    And also it’s giving me an error on the expression at line 11. Is there something I’m missing?

    Thank you so much!

  • Skylar Moran

    July 15, 2015 at 11:34 pm

    “Error at line 11 in property ‘Opacity’ or layer 60
    Expected: ).”

    I tried adding . after the ) on what I think is considered line 11 but I’m still getting the error.

  • Kevin Camp

    July 15, 2015 at 11:42 pm

    the expression code box converted all the < > (greater than less than signs) to &lt and &gt (html tag equivalents).

    i’ll try pasting this as preformated text:

    opacityMin = 0;
    opacityMax = 100;
    
    fadeInStart = 600;
    fadeInEnd = 500;
    fadeOutStart = 300;
    fadeOutEnd = 200;
    
    y = toComp(anchorPoint)[1];
    
    if (y <= fadeOutEnd || y >= fadeInStart){
    	opacityMin;
    }else if (y < fadeInStart && y > fadeInEnd){
    	linear(y, fadeInEnd, fadeInStart, opacityMax, opacityMin);
    }else if (y < fadeOutStart && y > fadeOutEnd){
    	linear(y, fadeOutEnd, fadeOutStart, opacityMin, opacityMax);
    }else{
    	opacityMax;
    }

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

  • Skylar Moran

    July 16, 2015 at 3:04 am

    Oh… lol. Now it works!

    Thank you for helping me with this so kindly. I really, really appreciate it. I will learn enough about expressions to not sound like a doofus one day! For now, you saved my evening. 🙂

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