ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

replace comp through input from another comp

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Bas v Breugel
replace comp through input from another comp
on Mar 29, 2018 at 10:40:57 am
Last Edited By Bas v Breugel on Mar 29, 2018 at 10:42:22 am

Hi Guys,

Im trying to find if this allready has been asked in the forums, but not quite sure how to formulate te question.

In basic;
I have one composition('INPUT') in where I have a text layer with the word 'FRA'
In the second compostion ('OUTPUT') I have a precomp('flagFRA') which is the flag of France.
There are 167 precomp flags in the Project panel in the folder 'Countries'.

Question;
Is there an expression, when you change the word to 'BRA' in the INPUT comp, the flag in the OUTPUT is replaced to the flag of Brasil ('flagBRA')?

Or do all 167 precomp flags have to be in the OUTPUT comp and on shy, and when the word BRA is typed the flagBRA becomes visible.

Not sure if this is the most logical way to get this setup done...


Return to posts index

Jamie Bradshaw
Re: replace comp through input from another comp
on Mar 29, 2018 at 11:08:20 am

In you have all your flags in your OUTPUT comp, but use this expression on their opacity..


textLayer = comp("INPUT").layer("TextLayer"); // <-- your text layer might have a different name

str1 = thisLayer.name.split("flag")[1];
str2 = textLayer.text.sourceText

if (str1 == str2) {
100;
} else {
0;
}


...then I think that should give you the results you're after?


Return to posts index

Bas v Breugel
Re: replace comp through input from another comp
on Mar 29, 2018 at 11:37:27 am

Yes, that works! Thank you

Only slight issue could be that you have to use caps to make it work, it will be case sensitive.

I tried putting the text format option on 'all caps', but even then, you would need to type it holding shipt/caps.


Return to posts index


Jamie Bradshaw
Re: replace comp through input from another comp
on Mar 29, 2018 at 11:42:50 am


textLayer = comp("INPUT").layer("TextLayer"); // <-- your text layer might have a different name

str1 = thisLayer.name.split("flag")[1];
str2 = textLayer.text.sourceText;
str1 = str1.toUpperCase();
str2 = str2.toUpperCase();

if (str1 == str2) {
100;
} else {
0;
}


Return to posts index

Bas v Breugel
Re: replace comp through input from another comp
on Mar 30, 2018 at 9:09:09 am

Thanks Jamie, that solved it.

I build the entire project but I noticed the aep file was getting gigantic (105 mb).
The project is a Top 10 ranking. So every postion has its own composition. And all these 10 comps have the 167 flags hidden in them.
I guess there is the bottleneck.

Idea.
Have one compostion called 'FLAGS' with a timeline of 167 frames. All 167 flags in there are 1 frame length stagered over the timeline.
In the INPUT comp you select with the same text input but it referrences to a framenumber in the FLAGS comp. In the Output comp is the Flags comp with a timefreeze and through the input expression it goes to the matching flag? I guess somewhere the 3 letter flagname should alphabatticly match the framenumber?

Is that a plausible idea?




Return to posts index

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