 Adobe After Effects Expressions ForumIf/else multiple expression
If/else multiple expression
by aniello ferrone on Nov 17, 2019 at 8:43:54 pm

Hi guys,

Could you help me with this sum / if else expression?
I think I did'nt insert one element correctly

Thank you so much
Aniello

```x = transform.anchorPoint; y = transform.anchorPoint; r1 = comp("Rigo 1").layer("Text 01"); r2 = comp("Rigo 2").layer("Text 01"); r3 = comp("Rigo 3").layer("Text 01"); r4 = comp("Rigo 4").layer("Text 01"); sum = (r1.text.sourceText.length?1:0) + (r2.text.sourceText.length?1:0) + (r3.text.sourceText.length?1:0) + (r4.text.sourceText.length?1:0); [x, y]; if(sum == 2){ [x, -296]; }else { if(sum == 1){ [x, -354]; } else { if(sum == 3){ [x, -270]; else [x, -231]; }```

Aniello Ferrone
Viral Video Editor
www.fanpage.it

Re: If/else multiple expression
by Dan Ebberts on Nov 17, 2019 at 11:05:00 pm

I'm not sure this is exactly what you're trying to do, and I haven't tested it, but I think I'd set it up more like this:

r1 = comp("Rigo 1").layer("Text 01");
r2 = comp("Rigo 2").layer("Text 01");
r3 = comp("Rigo 3").layer("Text 01");
r4 = comp("Rigo 4").layer("Text 01");
sum = (r1.text.sourceText.length?1:0) + (r2.text.sourceText.length?1:0) + (r3.text.sourceText.length?1:0) + (r4.text.sourceText.length?1:0);
s = clamp(sum,0,4);
myArray = [value,-354,-296,-270,-231];
y = myArray[s];
[value,y]

Dan