FORUMS: list search recent posts

# sum up all the values of the frames before

FAQ   •   VIEW ALL
 sum up all the values of the frames before on Feb 20, 2012 at 6:50:23 pm

hello,

i've got a really complicated problem, so i hope i can make myself clear:

i have a parameter z, which has a keyframed value on every frame.
i also have a parameter y, which depends on z AND the sum of all the values of y before the current frame (because the sum defines the time, at which my expression looks at z).

this is my expression (much simplified, but basically that's the principle):

```sum=0; for (i=0; i<=time-0.02; i+=0.02) { sum += ( y.valueAtTime(i) ); } (z.valueAtTime(sum);```

That's the expression to calculate y.
my comp is in 50fps, that's why in the loop the steps are 0.02s.

alright, now to everybody who could follow to this point:

the problem is, in the loop instead of the previously calculated value for y, it uses the value of y, which is defined before the expression (which is always 100, unless i gave it another value or even keyframed it - what i don't want, because i want the expression to define the value).

it's like in the curve-editor, you can also see the original value but if you check the box with the curve-sign, you see the curve after the expression. so in the loop the value before the expression is used instead of the value after the expression. this just to make clear the problem...

the strange thing is - if i use the value of y in any other expression, e.g. to move a null, it uses the value after the expression, just like it should be - so it seems like the loop is the problem?

any suggestions? i've been stuck on this for several days now... :/

Thanks for the help!
Noah

 Re: sum up all the values of the frames beforeon Feb 21, 2012 at 12:18:51 am

Expression results don't get passed from frame to frame, so there's no way for an expression to go back and retrieve its result from a previous frame. You have to somehow, at the current frame, calculate or recreate the value from the previous frame.

As you have observed, an expression on any property can retrieve previous expression-generated values from any other property, just not from the property hosting the expression.

Dan