Skip to main content
Participant
November 8, 2018
Answered

If/else issue since upgrading to CC19 (v16.0)

  • November 8, 2018
  • 2 replies
  • 7933 views

I just upgraded from AE 15.1.2, and I'm finding that this expression isn't working in v16.0. Does anyone know if there's a change to the way this needs to be written in v16.0?

I've got multiple layers, and I'm controlling which layer's opacity is at 100% by changing values on a slider (named Slider Control" that's on Null 1. Here's the expression that says if Slider Control is set to 1, then the opacity for the layer is 100, and if not, then it is 0:

if(thisComp.layer("Null 1").effect("Slider Control")("Slider")==1) 100 else 0

Opening a project that was made last week in AE 15.1.2, the expression hasn't changed at all, yet works perfectly. But the same expression used in a new project gives this error:

“Undefined value used in expression (could be an out of range array subscript?, an expression was disabled as a result of an error.”

I can't find any information on changes to expressions that will allow me to figure out how to get this to work in v16.0. Any help is appreciated!

This topic has been closed for replies.
Correct answer Dan Ebberts

Yes, if/else syntax is more strict with the new expression engine. This should work:

if(thisComp.layer("Null 1").effect("Slider Control")("Slider")==1) 100; else 0

or this:

if(thisComp.layer("Null 1").effect("Slider Control")("Slider")==1) { 100 }else{ 0 }

Dan

2 replies

Participant
November 8, 2018

Thank you so much Dan! They both worked perfectly. I wasn't able to find this in the expression language reference, is there a place I could have found this?

Dan Ebberts
Community Expert
Community Expert
November 8, 2018

There's a little about it here, but it doesn't really tell you what you have to do:

Expression language in After Effects

Dan

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
November 8, 2018

Yes, if/else syntax is more strict with the new expression engine. This should work:

if(thisComp.layer("Null 1").effect("Slider Control")("Slider")==1) 100; else 0

or this:

if(thisComp.layer("Null 1").effect("Slider Control")("Slider")==1) { 100 }else{ 0 }

Dan

easygoing_idea1549
Inspiring
February 16, 2019

I just had the same issue and am very glad i found this, so thanks once again, Dan! Strangely enough though, when i opened an old Project where i had used the old syntax, and converted to CC2019, it worked. Any Idea why? Is this Adobes way of giving me a "heads up" like they do with obsolete effects?

Dan Ebberts
Community Expert
Community Expert
February 16, 2019

I think old projects open with the Legacy ExtendScript engine enabled. If you go to File > Project Settings > Expressions and change the Expressions Engine to JavaScript, then your expression should break.

Dan