Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression to control opacity linked to comp position Y with slider control

  • Expression to control opacity linked to comp position Y with slider control

    Posted by Skylar Moran on August 2, 2017 at 5:35 pm

    Hello,

    I’m using an expression to trigger a fade in and fade out of text once it hits a certain position y in the comp. I want to link the position Y attribute in the expression to a slider control so that I can keyframe the point the fade out happens for multiple layers. Here’s the expression I’m using.

    Typically this expression would have pixel values after “fadeInStart” and etc, that’s where I want to point to a slider value instead of a fixed pixel point. This shows my attempt to do that, but it isn’t working in my comp. I’m not getting any expression errors but the fade in and fade out effect just isn’t happening no matter what my slider values are set to.

    I’ve probably written something wrong in here. Any help or advice would be appreciated!

    Skylar

    opacityMin = 0;
    opacityMax = 100;

    fadeInStart = thisComp.layer("Slider").effect("FADE IN START");
    fadeInEnd = thisComp.layer("Slider").effect("FADE IN END");
    fadeOutStart = thisComp.layer("Slider").effect("FADE OUT START");
    fadeOutEnd = thisComp.layer("Slider").effect("FADE OUT END");

    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;
    }

    Skylar Moran replied 8 years, 9 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    August 2, 2017 at 5:52 pm

    I think it will work if you include the Slider property in your slider paths:


    opacityMin = 0;
    opacityMax = 100;

    fadeInStart = thisComp.layer("Slider").effect("FADE IN START")("Slider");
    fadeInEnd = thisComp.layer("Slider").effect("FADE IN END")("Slider");
    fadeOutStart = thisComp.layer("Slider").effect("FADE OUT START")("Slider");
    fadeOutEnd = thisComp.layer("Slider").effect("FADE OUT END")("Slider");

    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;
    }

    Dan

  • Skylar Moran

    August 2, 2017 at 5:56 pm

    That fixed it! Thank you!

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