ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Error with expression when using slider to control image visibility

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Elisabetta Bruno
Error with expression when using slider to control image visibility
on Jan 22, 2019 at 4:38:06 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;


Return to posts index

Kalleheikki Kannisto
Re: Error with expression when using slider to control image visibility
on Jan 22, 2019 at 5:55:27 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


Return to posts index

Dan Ebberts
Re: Error with expression when using slider to control image visibility
on Jan 22, 2019 at 5:59:21 pm

Try changing the last line to:

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


Dan



Return to posts index


Elisabetta Bruno
Re: Error with expression when using slider to control image visibility
on Jan 23, 2019 at 9:14:15 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!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]