ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Position over time relative to width of comp

FAQ   •   VIEW ALL
 Position over time relative to width of comp on Apr 23, 2013 at 9:04:06 am

Hi

I'm trying to find an expression that will control the position of a layer over the time of the comp relative to the width of the comp.

So move layer from x=0 to x =100% the width of the comp over the length/time of the comp.

I looked into thisComp.width and thisComp.duration but keep hitting dead ends. Any help appreciated, thanks.

 Re: Position over time relative to width of compon Apr 23, 2013 at 11:57:13 am

One method would be to use an ease expression added to position.

```myTime = thisComp.duration; myWidth = thisComp.width; y =300; ease(time,0,myTime,[0,y],[myWidth,y])```

The expression says that from time 0 to myTime(comp duration) move from 0 to the myWidth(comp Width). You might want to adjust the start postion to a negative number to start your move offscreen. You could change the myWidth to myWidth =thisComp.width+thisLayer.width; that should move the layer offscreen at the finish also.

here's the project in action:5899_moveexpressionovertime.aep.zip

Johnny Cuevas, Editor
Thinkck.com

"I have not failed 700 times. I have succeeded in proving that those 700 ways will not work. When I have eliminated the ways that will not work, I will find the way that will work."
---THOMAS EDISON on inventing the light bulb.

 Re: Position over time relative to width of compon Apr 23, 2013 at 12:03:04 pm

Made a couple of adjustments so the layer starts and ends offscreen(as long as the anchor point is in the center of the layer)

```myTime = thisComp.duration; myWidth = thisComp.width+(thisLayer.width/2); y =300; ease(time,0,myTime,[(0-(thisLayer.width/2)),y],[myWidth,y])```

Here's an updated project with both methods, one linear and one with easy ease.
5900_moveexpressionovertimev2.aep.zip

Johnny Cuevas, Editor
Thinkck.com

"I have not failed 700 times. I have succeeded in proving that those 700 ways will not work. When I have eliminated the ways that will not work, I will find the way that will work."
---THOMAS EDISON on inventing the light bulb.

 Re: Position over time relative to width of compon Apr 23, 2013 at 6:58:04 pm

Thanks John that is just the ticket! :)

 Re: Position over time relative to width of compon Apr 23, 2013 at 2:00:32 pm

I'm puzzled why you would need an expression to do this. It only takes two position keyframes, one at the beginning of the comp and one at the end of the comp. Done.

Dave LaRonde
Former Sr. Promotion Producer
KCRG-TV (ABC) Cedar Rapids, IA

 Re: Position over time relative to width of compon Apr 23, 2013 at 7:01:00 pm

Picking up an existing project with about 50 comps needing this and I just wondered if there was an easy way to do it with expressions. I know if doesnt save me that much time but still I wondered :)

 Re: Position over time relative to width of compon Apr 23, 2013 at 7:07:01 pm

In that case, I guess we're now down to a matter of seconds.

Making two keyframes to move the comp would take about 15 seconds, I reckon. Let's be pessimistic and say 30 seconds. I'm not entirely sure how long it would take to copy and paste an expression.

Dave LaRonde
Former Sr. Promotion Producer
KCRG-TV (ABC) Cedar Rapids, IA

 Re: Position over time relative to width of compon Apr 23, 2013 at 8:39:31 pm

[Dave LaRonde] "I'm not entirely sure how long it would take to copy and paste an expression."

Super-speedy.

Add the expression to one layer. Select the property, then Edit > Copy Expression Only. You only need to do this once.

From there on out, select a layer you want to apply the expression to and hit Ctrl-V (Cmd-V on a Mac). You can do this as many times as you like while the expression is on the clipboard.

Walter Soyka
Principal & Designer at Keen Live
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
RenderBreak Blog - What I'm thinking when my workstation's thinking
Creative Cow Forum Host: Live & Stage Events