ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

else if statements +3 values

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Ronan De Lacy
else if statements +3 values
on Jul 9, 2020 at 8:35:29 am
Last Edited By Ronan De Lacy on Jul 9, 2020 at 8:40:34 am

Good morning all,

I have a real quick question re/ the syntax of my expression.

I have a text layer with an opacity range selector applied. The words of the sentence appear on beat, and can be changed via a numerical input from a spreadsheet. All of this is working for 2-3 words, however if I use the same expression for anymore than 3 words I get an error and I can't figure out where I'm going wrong.

Any help greatly appreciated!

Thanks in advance,
Ronan

Here's the working expression for 3 words
key1 = thisComp.layer("control-layer-name-1").effect("Slider Control")("Slider");
key2 = thisComp.layer("control-layer-name-2").effect("Slider Control")("Slider");
key3 = thisComp.layer("control-layer-name-3").effect("Slider Control")("Slider");
if(numKeys > 2){
if (time < key(2).time){
key1;
}else if (time < key(3).time){
key2;
}else{
key3;
}
}else{
key1;
}


and here's the expression for 5 words that I can't get to work

key1 = thisComp.layer("control-layer-name-1").effect("Slider Control")("Slider");
key2 = thisComp.layer("control-layer-name-2").effect("Slider Control")("Slider");
key3 = thisComp.layer("control-layer-name-3").effect("Slider Control")("Slider");
key4 = thisComp.layer("control-layer-name-4").effect("Slider Control")("Slider");
key5 = thisComp.layer("control-layer-name-5").effect("Slider Control")("Slider");
if(numKeys > 2){
if (time < key(2).time){
key1;
}else if (time < key(5).time){
key2;
}else{
key3;
}else{
key4;
}
else{
key5;
}
}else{
key1;
}


Return to posts index

Filip Vandueren
Re: else if statements +3 values
on Jul 9, 2020 at 9:57:00 am

Hi There, you can only have 1 "final" else in an if/if else/chain.
Meaning every else before it also needs a (unique) if condition:


key1 = thisComp.layer("control-layer-name-1").effect("Slider Control")("Slider").value;
key2 = thisComp.layer("control-layer-name-2").effect("Slider Control")("Slider").value;
key3 = thisComp.layer("control-layer-name-3").effect("Slider Control")("Slider").value;
key4 = thisComp.layer("control-layer-name-4").effect("Slider Control")("Slider").value;
key5 = thisComp.layer("control-layer-name-5").effect("Slider Control")("Slider").value;

if(numKeys > 2){
if (time < key(2).time){
key1;
} else if (time < key(3).time){
key2;
} else if (time < key(4).time){
key3;
} else if (time < key(5).time){
key4;
} else {
key5;
}
}else{
key1;
}




Return to posts index

Ronan De Lacy
Re: else if statements +3 values
on Jul 9, 2020 at 10:09:27 am

Hey Filip - Thanks so much... I've been tearing my hair all morning trying to figure out where I went wrong!!


Return to posts index

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