ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# If/else multiple expression

FAQ   •   VIEW ALL
 If/else multiple expression 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[0]; y = transform.anchorPoint[1]; 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
http://www.fanpage.it

 Re: If/else multiple expressionon 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[1],-354,-296,-270,-231];
y = myArray[s];
[value[0],y]

Dan