Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Error with expression when using slider to control image visibility

  • Error with expression when using slider to control image visibility

    Posted by Elisabetta Bruno on January 22, 2019 at 4:38 pm

    Hi All.

    I have been looking at how to use the slider function in After Effects to toggle visibility of backgrounds. There are a couple of posts on this forum but I just can’t seem to get the expression to work.

    This is what I have done:

    1. Created a null object and called it “BG Controller”
    2. Dropped a slider effect onto it
    3. Added an expression to the opacity property of the images (see below)
    4. After Effects says there is an error in the expression and it doesn’t work

    The slider range has been set to 1 through 3.

    Any reason why this wouldn’t work?

    ctrl = thisComp.layer("BG Controller").effect("Slider Control")("Slider");
    if ( Math.floor( ctrl ) == 1 ) 100 else 0;

    Elisabetta Bruno replied 7 years, 8 months ago 3 Members · 3 Replies
  • 3 Replies
  • Kalleheikki Kannisto

    January 22, 2019 at 5:55 pm

    If you’re in AE CC2019, the expression language has changed some and may require more accurate syntax, such as curly brackets around the IF ELSE outputs. (I don’t know the details, haven’t installed the latest myself.)

    If in an earlier version, the simplest reason would be that the name of the layer doesn’t match exactly (they’re case sensitive), your best bet is to copy and paste the layer name.

    Kalleheikki Kannisto
    Senior Graphic Designer

  • Dan Ebberts

    January 22, 2019 at 5:59 pm

    Try changing the last line to:

    ( Math.floor( ctrl ) == 1 ) ? 100 : 0;

    Dan

  • Elisabetta Bruno

    January 23, 2019 at 9:14 am

    ( Math.floor( ctrl ) == 1 ) ? 100 : 0;

    Hi,

    That worked! I guess the issue was with the different syntax in CC 2019.

    Thank you very much, I was trying to get this to work for hours!

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