Ease a camera between variable positions using only expressions
I may be close to a solution thanks to Dan's amazing post on random motion with random durations: http://www.motionscript.com/mastering-expressions/random-1.html
I've made a template for creating a dynamic Facebook timeline. The timeline shrinks or grows as you modify the number of posts, the size of the pictures, the number of comments, etc. so keyframes are not an option. Each post is its own comp, storing its own "height" and "image centre" (distance from the top of the post to its focal point which is the centre of the post's main image) in slider controls.
The problem: I'm trying to automate the movement of a camera so it eases from the image centre of one post to the next, and the next, and so on, until it reaches the end of the timeline. I've applied an expression to the Y Position of a null, but I can't get the logic right. It seems like I need to declare the variable "endPos" on the 2nd last line without resetting it. Anyone know how I can do that? Or see a better solution?
In summary, here's the result I'm expecting:
0 to 3 seconds: no movement
3 to 8 seconds: move to an endPosition equal to the Image Centre of Post1
8 to 13 seconds: move to an endPosition equal to the Image Centre of Post2 + the height of all previous posts
13 to 18 seconds: move to an endPosition equal to the Image Centre of Post3 + the height of all previous posts
18 to 23 seconds: move to an endPosition equal to the Image Centre of Post4 + the height of all previous posts
and so on...
With help from Jeff Turnham I was able to fix it using functions: