You have to use valueAtTime() to retrieve different positions at different times. the rest is unclear. Your description is somewhat confusing and you are throwing together different unrelated things.
Hey Wow, you guys are really quick here.
Sorry didn't want to confuse anyone here.
I will go a little more into it.
If i am only taking the x value of the position and compare the actual state of x value with the satus of the x value of the keyframe before.
i will take this two values x1 and x2 to take the difference between them. With this new value.
i can modify the angle of the rotation between -90 and +90.
Know what i mean?
but i am not sure if valueattime works in this case because i need the information dynamic.
How more dynamic can it get?
That's all there is to it. Expressions are evaluated after keyframe data and even if it were the other way around, you could still control evaluation order by applying the expression to a different layer...