1 person found this helpful
One thing to note: Expressions are case-sensitive. I see that you have 'ValueAtTime', not 'valueAtTime'.
Also, valueAtTime takes an argument, which represents the time from which to read the value.
Thank you Todd, that was helpfull!
It's still not working though, now the error message says
"Object of type Function found where a number, array or property is needed"
I think the solution to this is something obvious and simple, but I couldn't find anything by searching.
Any help will be appreciated!
You can get past that error by heeding the second paragraph in my first message. I.e., you need to give valueAtTime its argument.
Thanks again for helping out!
I'm not sure how to tell valueAtTime to take the current value for the parameter (x-position). I tried to put in valueAtTime(time) and valueAtTime(10) but the layer keeps jumping back to it's beginning position.
So I guess the question goes: How do I tell valueAtTime to return the current value for my property?
1 person found this helpful
OK, now that we've gotten you past the two syntax errors, we can finally talk about the real issue.
The valueAtTime method queries the keyframe-based value of the property at the time specified. It doesn't look at the expression-based values.
BTW, why aren't you just using keyframes for this? Perhaps you have some reason for wanting to use an expression here, but if all that you're trying to do is move a layer horizontally and then stop, that's something that you can do easily with two keyframes.
Thanks for educating me Todd, it's appreciated!
Anyway I'm using expressions just because I'm trying to learn them (you are right that this could be done with keyframes too). As you see I have still a loong way ahead of me! But I have had a similar kind of problems with expressions many times and would like to know if there is a solution.
In other words, is there any way to make an expression stop and hold it's current value at that point in time?
To hold a specific value that in itself is based on other expression values it would have to run in a loop (while())and be triggered by a specific criteria. Unless it is really necessary, I would avoid it, as AE's model basically re-evaluates the expressions for every frame to derive the value, so as time progresses, it gets slower and slower, because more frames amass. Converting the animation to keyframes and cleaning up the excess often is more efficient, unless you really need to be it dynamic and changeable....
PS: You can of course always use time-remapping on a pre-comp. Since it influences the comp time, expressions will respect any hold animation on it...
Message was edited by: Mylenium
Have you thought about tying the value in the expression to a Slider (Expression Controls > Slider). Then the value that you want to hold can be controlled by keyframing the Slider effect.
Not sure if that gets you anywhere that you couldn't have gone with just regular keyframes, but the Slider effect is how you control the wiggle expression (otherwise it will wiggle with the same values for the entire layer). Using Slider, you can start off with no wiggle, ramp it up, and then hold on that value, or ramp back down.