Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects Expressions › X position based on Y (kind of)

  • X position based on Y (kind of)

    Posted by Mike Olson on August 21, 2011 at 7:36 pm

    I have about 50 postage stamp sized images all stacked vertically in a row. I need to scroll these images vertically very quickly and at the same time, as each image enters the center of the comp, they (each image in turn) need to shift to the left by 35 pixels or so, then back into position. The end effect should look like a sorting machine examining each image (only very fast).

    At the moment, I have all the images aligned in one comp. I have tried attaching them to a null to get the vertical movement and added keyframes to each image for the horizontal move, but it’s too difficult to keep when the horizontal move happens at the same location in the comp as the vertical move (the null) must ease out and in, thereby throwing off when each image shifts horizontally.

    I am stumped as to how to go about it so any help would be greatly appreciated, thanks in advance!

    Mike Olson replied 15 years, 1 month ago 2 Members · 6 Replies
  • 6 Replies
  • Dan Ebberts

    August 21, 2011 at 8:36 pm

    As an example, this should ease your stamp 35 pixels to the left as it goes from 5 pixels below the center of the comp to 5 pixels above.


    range = 5;
    shift = -35;

    p = toComp(anchorPoint);
    d = thisComp.height/2- p[1];
    if (d < 0)
    x = ease(d,-range,0,0,shift)
    else
    x = ease(d,0,range,shift,0);
    value + x

    Dan

  • Mike Olson

    August 21, 2011 at 8:59 pm

    You, sir, are brilliant! Your expression REALLY helps me out.

    Thank you for being so generous with your time and knowledge. Not to mention your patience in dealing with lost souls like myself.

    I am so very grateful!!

  • Mike Olson

    August 21, 2011 at 9:06 pm

    You, sir, are brilliant! Your expression REALLY helps me out.

    Thank you for being so generous with your time and knowledge. Not to mention your patience in dealing with lost souls like myself.

  • Mike Olson

    August 22, 2011 at 1:16 am

    Sorry for the double post…

    Now I’m going to be selfish and ask for a variation:

    What if the images where positioned horizontally and I needed to have the images move up (or down) in the same fashion (as they moved from right or left)?

    I’m attempting to rework your code, but I’m not have any success.

    Once again, thank you in advance.

  • Dan Ebberts

    August 22, 2011 at 4:30 am

    This should work for up:


    range = 5;
    shift = 35;
    p = toComp(anchorPoint);
    d = thisComp.width/2- p[0];
    if (d < 0)
    y = ease(d,-range,0,shift,0)
    else
    y = ease(d,0,range,0,shift); value + [0,y]

    For down, just change shift to -35.

    Dan

  • Mike Olson

    August 22, 2011 at 6:49 pm

    Excellent! Thank you so much.

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