3 Replies Latest reply on Oct 28, 2014 12:55 AM by caststupider Branched from an earlier discussion.

    animate object with expression

    caststupider Level 1

      how can I animate an object with a expression?


      for example:


      -the object moves in 3 seconds 500px further

      -or from second 15 of the video, moves the object 500px in 3 seconds.

      and i often get this error message:

      array part can not take more than one value

      -how can I avoid what should I do

      thanks for your answers

      I hope someone can help me

      --sorry for my english i'm from Switzerland--

        • 1. Re: animate object with expression
          Dave LaRonde Level 6

          Why bother to use an expression?  You can do the same thing with keyframes and a little bit of arithmetic.

          • 2. Re: Re: animate object with expression
            Rick Gerard Adobe Community Professional & MVP

            Your expression needs a time reference, which returns one value, and a position reference which is either a 2 or 3 place array written like this [100, 300]


            If you want to write an expression that moves a layer from it's original position 500 pixels to the left in 3 seconds then you just have to divide 500 X 3 then use time * the result and add that value to the current position of X. I'd write it something like this:


            d = 500;  // distance in pixels

            s = 3;  // time in seconds

            r = d / s; // pixels per second

            cv = value[0];  // current value of x

            nx = cv + (time * r); // add movement to the right


            [nx, value[1]]

            Movement will start from at the first frame of the comp. You can use valueAtTime or inPoint or even the position of a marker to start the movement by simply doing a little more coding.

            • 3. Re: Re: animate object with expression
              caststupider Level 1

              Thank you for the answer, I will try it at home the same.

              it will certainly help me


              Now I understand the principle better already and have learned something