14 Replies Latest reply on Nov 22, 2016 2:58 PM by SuperSelrak

    Nested comp with text expression

    DC B. 09 Level 1

      I have a comp with a text animation (about 5 layers + effects on some of them & keyframes). My idea was to create this as a "template" and use it throughtout the project for multiple lines of text in their separate comps (about 40 or so). Unfortunately I cannot seem to find the way to tie in the Text source field to anything in the parent comp to make that text change for each new parent comp. At the moment I can get this expression with a pick-whip from a "template" comp:

       

      comp("stat: Length").layer("stat text").text.sourceText

       

      But if I copy it to a new parent comp with a different text it still uses the old "stat: Length" parent comp. And the following doesn't work:

       

      parent.layer("stat text").text.sourceText

       

      What is the way to reference this text?

       

       

      PS. I need to group all the text animation in a single comp because I may need to change the duration of this animation later, so if I simply copy the animation "template" comp so many times it will require me to apply the change to all those copies.... I'm trying to find a simpler way. I also hope I'm clear with it?

        • 1. Re: Nested comp with text expression
          Todd_Kopriva Level 8

          To refer to the current composition (the one in which the expression sits), use the thisComp method. See "Global objects, attributes, and methods".

          • 2. Re: Nested comp with text expression
            DC B. 09 Level 1

            Thanks. I tried:

            thisComp.parent.layer("stat text").text.sourceText

            but I still get an error.

            • 3. Re: Nested comp with text expression
              Mylenium Most Valuable Participant

              There is no such thing as a parent method for comp items. Expressions don't care for project structure, references are always by absolute name. Your code will never work.

               

              Mylenium

              • 4. Re: Nested comp with text expression
                Todd_Kopriva Level 8

                I thought that he was trying to get the syntax such that he could copy and paste the same expression into different compositions so that the expression would work within any composition into which it was pasted.

                • 5. Re: Nested comp with text expression
                  DC B. 09 Level 1

                  Yeah, there seems to be no solution to reference a parent comp using expressions, so I ended up copying it 40+ times. That, by the way, maybe one of the things that you, Adobe guys, should consider in a new version of AE -- namely, relative references to comps and layers. It will be very handy.

                  • 6. Re: Nested comp with text expression
                    Mylenium Most Valuable Participant

                    Yeah, there seems to be no solution to reference a parent comp using expressions,

                     

                    Not exactly true. It is perfectly possible using the .name method and string filtering under the one condition that you actually have something to base that name on. Could be as easy as filtering by a numbering scheme for instance... It's just not a simple shorthand feature.

                     

                    Mylenium

                    • 7. Re: Nested comp with text expression
                      DC B. 09 Level 1
                      function(){return A.apply(null,[this].concat($A(arguments)))}

                      Mylenium wrote:

                       

                      Yeah, there seems to be no solution to reference a parent comp using expressions,

                       

                      Not exactly true. It is perfectly possible using the .name method and string filtering under the one condition that you actually have something to base that name on. Could be as easy as filtering by a numbering scheme for instance... It's just not a simple shorthand feature.

                       

                      Mylenium

                       

                      Yes, but it will still be an absolute reference and that is my "beef" with expressions. You see in my example it would've saved me lots of time if I could use one comp and reference it in the rest of 39 comps.

                      • 8. Re: Nested comp with text expression
                        Mylenium Most Valuable Participant

                        Yes, of course it's still absolute. I don't quite get why you are seeing this as a problem, though. Your case presents the classical unresolvable ambiguous logic case that cannot be handled in a clean fashion automatically. By all rights, any sub-comp can be part of multiple comps as can those parent comps again be part of otehr comps that may in themselves refer to the original sub-comp. I could draw up a fancy matrix of al lthe possible combinations, but just to keep it short: What you are attempting to do would not work, even if expression were aware of project hierarchy. At least not in this simplistic manner. It would require multiple test conditions chained together in possibly endless if()else() constructs. To the avarage user this is not practical at all and it isn't even practical for just 40 comps...

                         

                        Mylenium

                        • 9. Re: Nested comp with text expression
                          DC B. 09 Level 1

                          OK, here's the exact situation I was working on. I needed it to implement scrolling credits. Each of the title lines had a complex set of layers + animation on them that had to be repeated over and over again for each line. My idea was to create a template comp and reuse it for each consecutive line. One would say to simply copy it over and over to achieve what I want, but such approach has two major downsides:

                           

                          1. If I want to change something I'd have to do it 40 * number changes.

                           

                          2. It obviously makes the project unnecessary large.

                           

                           

                          Is there any special way you'd do it?

                          • 10. Re: Nested comp with text expression
                            Mylenium Most Valuable Participant

                            And what if you did all the text animation in just one comp by repeatedly placing the background and animating the source text? You can always splice out separate chunks be setting up multiple render items then. I'm still unsure what exactly is going on. This really sounds like a problem with how you constructed the whole thing....

                             

                            Mylenium

                            • 11. Re: Nested comp with text expression
                              A. Cobb Level 3

                              I would do this, and have done this (or things very similar) by duplicating the comp for each item and, if possible, using the name of the comp to drive the contents of the text.

                               

                              Mylenium might already have explained this in so many words, but the problem with the approach you are attempting is that in AE a comp can only exist in one state.  If you open a comp and move the current time indicator to a given frame, it will, barring bugs or glitches, always render that frame the same way.  The consequence of this is that that frame will appear the same anywhere that comp is nested (the one exception being when you enable collapse transformations on the nested comp, and that only means the same comp data might be rendered differently).

                               

                              This is not to say that what you want couldn't be implemented, or that it wouldn't be tremendously useful either, just that it would require a major rethink on Adobe's part of what the user should expect when viewing a comp whose contents change contextually, and this isn't a trivial design problem.  The same problem applies to a perennial favorite among unimplemented feature requests: the ability to view and edit the contents of nested comp layers from within a parent comp.

                              1 person found this helpful
                              • 12. Re: Nested comp with text expression
                                DC B. 09 Level 1

                                A. Cobb, where were you before? I'm all done with it by now but your idea of using the layer name as the source for the text is brilliant. Just from the curiosity, how would you reference it with expressions?

                                • 13. Re: Nested comp with text expression
                                  A. Cobb Level 3

                                  Sorry, I haven't been reading the forum as much as I used to.

                                   

                                  Just to be clear, it's the comp name, not the layer name.  To get the name of the comp, you would append ".name" to the comp reference.  Most likely it would be "thisComp.name".

                                  • 14. Re: Nested comp with text expression
                                    SuperSelrak

                                    Hi again,

                                     

                                    Basically, up. I am stuck with tens of flags, all as separate comps with no common content, and what it if I don't quite like their animation once I see them all together or want to add an effect to all of them ?

                                     

                                    I still don't see how linking anything fro within the template comp to the outside world solves the problem, because the comp only ever exists in one state, that's one of the basic principles of After Effects. You can only draw fixed-state links from the comp to the outside world.