6 Replies Latest reply on Mar 30, 2010 4:15 AM by Rick Gerard

    How do i get expressions to work across compositions?

    345712473471 Level 1

      I have two comps, each with one layer, and i want the x position of comp 1 to inversely control the x position on comp 2. Ive been studying expressions for the past week but this is a bit above any tutorial i have found.

        • 1. Re: How do i get expressions to work across compositions?
          Todd_Kopriva Level 8

          Just address the other composition by its name. For example:

          comp("Comp 2").layer("Yellow Solid 1").transform.position

           

          You don't even need to know anything about expression syntax to do this. Just use the pickwhip. (Tip: Dock one Timeline panel under the other one to use the pickwhip across compositions.)

           

          two_Timeline_panels.png

          • 2. Re: How do i get expressions to work across compositions?
            345712473471 Level 1

            I tried writing that but it kept giving me errors, but then i used the pickwhip which input the same thing and it worked. You guys over at adobe really got to get your **** straight.

            • 3. Re: How do i get expressions to work across compositions?
              Todd_Kopriva Level 8

              > You guys over at adobe really got to get your **** straight.

               

              Is there something about the help that you got here that you're unhappy with?

               

              If you have a bug to report or a feature enhancement to request, here's the link.

              • 4. Re: How do i get expressions to work across compositions?
                Rick Gerard Adobe Community Professional & MVP

                All it takes is a single punctuation error, or a capitalization error with PHP, Java, or Expressions to foul up the expression. Expression language is more forgiving than many programming languages but it still follows strict rules. If you typed a line of code that didn't work, then you used the pickwhip and it did, then you had type-o the first time. I've been writing expressions since they were introduced and I still make type-o's all the time. Your reply sounds like you're taking your frustrations out on folks that are trying to help. That's no way to make friends in this community.

                 

                I spent a fair amount of time a few days ago on your thread about mirrored or opposing action. Other readers can find the thread here. I gave solutions for parented layers or normal layers in 2D and 3D space. You originally stated that you had pre-composed the layers, but I said that as I understood your project, pre-composing was not necessary. With each answer you revealed more details about your project. I kept adjusting my answers to fit the new description of your problem. No mention was made about whether the solution offered at the end of the thread worked for you and you never provided a screen shot or flowchart of your composition to help any of us figure out what you were trying to do.

                 

                I'll try one more time to help you out. To make any of the expressions offered in the previous thread work "across compositions" all you have to do is to replace the thisComp.layer("Master") statement with a comp("Comp 1").layer("Master") statement. This language is explained in the Adobe help files under Expression Language Reference in the first section "Global objects, attributes and methods". The explanation is as clear as any help file for any programming language I've ever read.

                 

                Opposing action for the Position property of the Slave layer in "Comp 2" controlled by the movement of the Master layer in "Comp 1" could be written like this:

                 

                i = [thisComp.width/2, thisComp.height/2];
                

                mp = comp("Comp 1").layer("Master").position;

                (i) - mp + i

                 

                Without a better idea of what you are trying to accomplish this is about as far as I can go. If you'd like some private tutelage I'm available at my usual hourly rate. If you'd like free answers show a little appreciation.

                • 5. Re: How do i get expressions to work across compositions?
                  345712473471 Level 1

                  I pm'd you in reply to your request for me to email you my comp but i never heard back, so here i am trying to figure out why when i type in an exact line of code it doesnt work but when the pickwhip does it automatically it does. I do appreciate the help rick, but it shouldnt be the responsbility of kind people like you to explain how to code when adobe has all the resources in the world to create a "creative" scripting language that can be just as easily written

                   

                  "one times two" as 1*2, or

                   

                  "make the x value of the position of layer1 of comp1  inversely control the x value of the position of layer1 of comp2" instead of

                   

                  i = [thisComp.width/2, thisComp.height/2];
                  mp = comp("2").layer("1.avi").transform.position;

                   

                  (i) - mp + i

                   

                   

                  seriously, middle school math? This is basically saying to subtract the x and y positions of the other comp from the center of this comp and add the center of this comp to the result. I cant even begin to make sense of that.

                  • 6. Re: How do i get expressions to work across compositions?
                    Rick Gerard Adobe Community Professional & MVP

                    I don't usually look at my PM unless there's a request on the forum thread. I don't answer forum questions in private messages. It is unfair to others that are following the threads.

                     

                    Let me try and explain the expression by explaining the concept then using some numbers. To calculate the change in value you subtract the new value from the original value. This gives you the offset value. Adding the offset value to the original value gives you an adjusted offset equal to the original position plus the offset. In other words if you offset 100 to the right of the original position the adjusted offset is 100 to the left of the original position. If the original offset is 50 less than the original value the adjusted offset is 50 more.

                     

                    Let's say that the composition size is 400 X 400. This means that the default position for any layer is 200, 200. Let's just look at the value of X.

                     

                    If the Master layer is moved to the left by 100 pixels the new position is X = 100.  To calculate the offset subtract the new position subtract the new position from the original position. 200 (the comp center or original position) - 100 (the current position of the Master) = 100. Add 100 to the default position of the Slave layer or center of the comp and you get 300 for the new position of the Slave layer. The offset (100 pixels) is equal to the  change in position of the Master layer but in the opposite direction.

                     

                    Change the position of the Master to 350 and recalculate. 200 minus 350 equals negative 150. Next you add negative 150 to 200 and you get 50.  Like I said, it's just basic math. That should make sense of the expression.

                     

                    Now let's take on the assertion that Adobe should use "all the resources in the world" to create a "creative scripting language." Expressions use Java Script modified to understand things like layer names, position, rotation and color. That's about the only difference. Any Java math will work if you tell it what properties you wish to modify. Recreating a new scripting language from scratch is not only not necessary, but it would require tens of thousands of man hours and years of debugging. Learning Java is a lot like learning to speak Spanish. It's a vaguely familiar language that can be easily misunderstood when spoken incorrectly. Estoy poquito is completely different than estoy perdido and wont get you the help you need when you are lost. Even a new creative scripting language would have to be spelled correctly.

                     

                    You may need to step back a bit from your project and look at it in a new way. There's no one right way to do anything in AE. A pencil sketch, storyboard or even a flow chart may be all that is necessary to figure a simpler approach to the project. Feel free to post any image that may help us understand your project.