Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions replace comp through input from another comp

  • replace comp through input from another comp

    Posted by Bas V breugel on March 29, 2018 at 10:40 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…

    Bas V breugel replied 8 years, 1 month ago 2 Members · 4 Replies
  • 4 Replies
  • Jamie Bradshaw

    March 29, 2018 at 11:08 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?

  • Bas V breugel

    March 29, 2018 at 11:37 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.

  • Jamie Bradshaw

    March 29, 2018 at 11:42 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;
    }

  • Bas V breugel

    March 30, 2018 at 9: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?


We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy