12 Replies Latest reply on Nov 1, 2016 11:14 AM by Rick Gerard

    Controlling the scale of a shape layer using slider control and expressions.

    mervinj71373917

      Hi everyone im fairly new to AE and im trying to get this sorted if anyone can provide any help.

       

      Basically I have two keyframes on the scale property of a shape layer. The first keyframe is at 0% and the second is at 15%. Id like to control the second keyframe

      using a slider.. Can anyone point me in the right direction please. Thanks

        • 1. Re: Controlling the scale of a shape layer using slider control and expressions.
          Roei Tzoref Adobe Community Professional

          add a slider control to your layer from the effects & presets panel. alt click on the stopwatch for the scale property and type this:

          x2 = effect("Slider Control")("Slider");

          x = linear(time,key(1).time,key(2).time,key(1).value[0],x2);

          [x,x]

          • 2. Re: Controlling the scale of a shape layer using slider control and expressions.
            Rick Gerard Adobe Community Professional & MVP

            Roei has given you an expression that requires two keyframes and uses the slider to modify the value of the second keyframe.

             

            My question is, what are you trying to do?  There are a few reasons to use a slider or other expressions control instead of just setting keyframes. If you use the solution provided setting a keyframe for the slider will have no effect and you will still need 3 keyframes for scale. If all you want to do is animate the slider to control the opacity then a much simpler expression would do the trick. Just declare s as a variable by typing s= and then drag the picwhip from the scale property of the shape layer to the value of the expressions slider then add a semicolon (;) and press return, then finish the  expression by creating an array by simply typing [s, s] and you're done.

             

            Now you can animate the scale by simply keep framing the slider. 

             

            From your question I cannot figure out what you are trying to accomplish or what you are trying to make more efficient, so a more detailed explanation would help anyone who is trying to help you figure out what you're trying to do.

            • 3. Re: Controlling the scale of a shape layer using slider control and expressions.
              Roei Tzoref Adobe Community Professional
              If all you want to do is animate the slider to control the opacity then a much simpler expression would do the trick. Just declare s as a variable by typing s= and then drag the picwhip from the scale property of the shape layer to the value of the expressions slider then add a semicolon (;) and press return, then finish the  expression by creating an array by simply typing [s, s] and you're done.

              or you could just pickwhip the property to the slider and click enter and be done with it.  Ae will write the variable and everything for you so you can save 10 seconds

              • 4. Re: Controlling the scale of a shape layer using slider control and expressions.
                mervinj71373917 Level 1

                Thanks for the help. I got it to work by using a null and added some more to the expression. Here is what I have now.

                 

                x2 = thisComp.layer("Null 1").effect("Slider Control")("Slider");

                x = linear(time,key(1).time,key(2).time,key(1).value[0],x2);

                [x,x]

                 

                The problem I have now is that the easy ease on the keyframe won't work anymore. Any solution to that problem. Thanks

                • 5. Re: Controlling the scale of a shape layer using slider control and expressions.
                  mervinj71373917 Level 1

                   

                  Basically I have a shape layer (A square). 2 keyframes on that shape layer on the scale property. first keyframe is at 0% percent so it's scaled right down. Second keyframe is at 50% (so now the square is bigger) I would like to be able to control that second keyframe with a slider. Hope this is a bit clearer than my previous post.

                   

                  Roei's solution worked for me but now I can't get it to easy ease. Any solution?

                   

                  Thanks for responding

                  • 6. Re: Controlling the scale of a shape layer using slider control and expressions.
                    Rick Gerard Adobe Community Professional & MVP

                    I am still not sure why you need to use slider set the value of the second key frame. It seems like a lot of work for no gain in productivity or efficiency in the workflow.

                     

                    If selecting the key frame and pressing F9 does not give you the easing that you want you will need to learn how to use the graph editor. If you are key framing the slider them the results will be unpredictable. The only way you'll know what you have is with a preview.

                     

                    Expressions and sliders and the like are there to improve efficiency. I cannot imagine what you have gained. That is what I wanted you to explain. I already understood exactly what you were trying to do. I just have no idea why.

                    • 7. Re: Controlling the scale of a shape layer using slider control and expressions.
                      Roei Tzoref Adobe Community Professional

                      Roei's solution worked for me but now I can't get it to easy ease. Any solution?

                      you have taken control of the keyframes using an expression, this means the easing shortcuts or the graph editor won't help you for the scale keyframe. in the expression, instead of linear, change it to ease:

                      x = ease(time,key(1).time,key(2).time,key(1).value[0],x2);

                      • 8. Re: Controlling the scale of a shape layer using slider control and expressions.
                        mervinj71373917 Level 1

                        Thanks alot Roei, that worked. Final problem i have now is that I need to incorporate your expression with some that I already for some other shape layers. It's sort of a bounce effect expression (also on the scale property). Is it possible to put the two together?

                         

                        amp = .1;

                        freq = 2.0;

                        decay = 4.0;

                         

                        n = 0;

                        if (numKeys > 0){

                        n = nearestKey(time).index;

                        if (key(n).time > time){

                        n--;

                        }}

                         

                        if (n == 0){ t = 0;

                        }else{

                        t = time - key(n).time;

                        }

                         

                        if (n > 0){

                        v = velocityAtTime(key(n).time - thisComp.frameDuration/10);

                        value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);

                        }else{value}

                        • 9. Re: Controlling the scale of a shape layer using slider control and expressions.
                          mervinj71373917 Level 1

                          Rick I am going to use the code he gave me to control the scale for a number of shape layers.

                          • 10. Re: Controlling the scale of a shape layer using slider control and expressions.
                            Roei Tzoref Adobe Community Professional

                            I am hardly an expressionist. I would advise you to try in the expression forum here: After Effects Expressions or here: CreativeCOW

                            • 12. Re: Controlling the scale of a shape layer using slider control and expressions.
                              Rick Gerard Adobe Community Professional & MVP

                              The only way I can see your approach as being useful and efficient is if you want to set a bunch of beginning and ending keyframes and the ending keyframes are all at a different time and you want to be able to use the same value for each ending keyframe. If that's what you are doing then an explanation in your first post with those kinds of details would have helped us help you in the most efficient way possible.

                               

                              If everything is happening at the same time then a much simpler approach would be to set up a controller layer with one slider, or two if you want to break apart the X and Z scale values, or even a position controller because it already has x y and if needed Z values that can be controlled, then just animate the expression controller.

                               

                              If I had a bunch of layers and I wanted the same thing to happen to the layers but at different times I would have written the expression so that it looked at layer markers or even in and out points of the layers. I have a commonly used and shared on this forum an animation preset that makes any layer of any size fly in from the right, bounce and then fall off the bottom of the screen. It's all based on in and out points. You just put the layer where you want it to land, set an in and out point, then apply the animation preset. EZ as that. I have about 200 of these that are based on the layer in and out points so doing dynamic text animations (lyric videos) or graphic explainer videos is as simple as designing the artwork in Illustrator so the assets are all in their hero or resting position, importing as a comp retaining layer sizes, setting in and out points for each layer based on the audio track (which has markers in it already that I added in Audition so I can see the text and know it's timing by just looking. Then I pick from the list and apply the appropriate animation preset. In most cases I can animate an already designed sentence or phrase in about 10 minutes.

                               

                              Just for fun, here's the animation preset: Dropbox - flyInBounceDropOut.ffx

                               

                              Give it a try with solid layers or Photos. Scale them, arrange them on the screen and then set in and out points for each layer and apply the animation preset. That's how to be efficient.