ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Is there any way to refer to multiple layers within one single expression?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Kevin Luca Aubert
Is there any way to refer to multiple layers within one single expression?
on May 31, 2018 at 12:27:08 pm

Hey everyone and thank you for reading my thread!

It's now been like 3 days that I spent desperately trying to figure this out myself and I dug to the bedrock of internet and found nothing working for me...
Here is the situation :

I'm making a 100% automated type-on animation in an old computer display look. The animation itself id done and working and now I can put whatever I want in source text and it auto animates and everything is easy to control without a single keyframe involved. Past that I went ambitious and also animated the crushing "beep" noises of type whenever some text is being typed. Everything works beautifully! But now I need to make multiple texts. The problem is that I want to keep the same sound layer to execute the expression for all the text layers. I tried to name all my text layers the same but It only takes the one with the nearest index# into account... I tried to use name.includes() but it is a JS function that is unknown to AE...
There must be a way but I can't figure it out... I'm sure the solution is right in font of me but is so obvious that I don't see it.

If anyone can help me you'll get my eternal respect and awe!

Here's the expression that needs to be solved.
P.S. : the audio level input is 1so i stands for in and o for out. So i = 1*-10 and o =1*-200 (o is to mute the sound basically)
The text layer is called TEXTE because I speak french too haha

i = audio.audioLevels*-10
o = audio.audioLevels*-200
if(thisComp.layer("TEXTE").effect("Texte")("Curseur")&lt;1){
o
}
else if(thisComp.layer("TEXTE").effect("Texte")("Curseur")&lt;(thisComp.layer("TEXTE").text.sourceText.length-1)){
i
}
else
o


Return to posts index

Kalleheikki Kannisto
Re: Is there any way to refer to multiple layers within one single expression?
on May 31, 2018 at 4:43:10 pm

You need to have the layers named differently and query ALL the layers within your IF statement using OR (|| in javascipt). So for instance with two layers this would be
... if(thisComp.layer("TEXTE 1").effect("Texte")("Curseur")<1 || thisComp.layer("TEXTE 2").effect("Texte")("Curseur")<1) ...
etc.

Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

Kevin Luca Aubert
Re: Is there any way to refer to multiple layers within one single expression?
on May 31, 2018 at 4:56:02 pm

Thanks Kalleheikki Kannisto for your quick answer, but I already tried this and it doesn't work... There's no error but it executes only for one of the two layers. 😭🤕

Kevin Luca Aubert – Interactive Media Designer


Return to posts index


Kalleheikki Kannisto
Re: Is there any way to refer to multiple layers within one single expression?
on May 31, 2018 at 5:25:52 pm

I don't know why it wouldn't. Can you detail your setup more, or take a screenshot showing which layers have which expressions on them?

Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

Kevin Luca Aubert
Re: Is there any way to refer to multiple layers within one single expression?
on Jun 1, 2018 at 11:00:19 am

Sir, Kalleheikki Kannisto,
I OWE you a billon thanks !!!! I tried on a test comp to express the opacity of a solid referring to the y position of 2 others to reproduce a condition similar to the one with the sound... and it worked just fine.
So i thought really hard and figured out that there were 2 problems... 1st my expression was way too messy and confusing, 2nd the two conditions (if() else if() else) worked fine for one layer but when it ran with 2 layers there was a contradiction (the argument was only true for one at a time).
So I cleared it all up and simplified it as follow and IT WORKED JUST AS EXPECTED!
You can't imagine how glad and thankful I am! It really helped me out because you sent me thinking in the right direction 😉
Guys, this man deserves a cookie, and a tight hug! 🏆

on = timeToFrames(time)%2*effect("Tonalité")("Niveau")
off = 0
a = thisComp.layer("TEXTE").effect("Texte")("Curseur")
a1 = thisComp.layer("TEXTE").text.sourceText.length-1
b = thisComp.layer("TEXTE 1").effect("Texte")("Curseur")
b1 = thisComp.layer("TEXTE 1").text.sourceText.length-1

if((0<a && a<a1) || (0<b && b<b1)) on else off


Kevin Luca Aubert – Interactive Media Designer


Return to posts index

Kalleheikki Kannisto
Re: Is there any way to refer to multiple layers within one single expression?
on Jun 2, 2018 at 12:27:55 pm

Most excellent. Happy that it helped. And working out the details yourself is much more educational. 😉

Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

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