The short version of what I'm looking to do is generate random rotation on a layer whenever there is change to the color value of the layer. This part I have figured out by using for a 10fps comp. In order to define "change" I'm just having after effects compare the color value of the layer at the current frame to the frame before it. The slider is creating a color value for the layer.
AA1 = effect("AA")("Slider").valueAtTime(time);
The issue I'm running into is that whenever there is NO change between the current frame and the frame before it, the rotation value returns to the value it was at the VERY first frame. What I'd like it to do is rotate randomly within that range whenever there is change and when there is not change, the rotation should stay at whatever the last random value generated was.
Expressions do not have any kind of memory that persists across frames; they are evaluated anew at each frame.
In other words, the calculated value on frame 1 does not overwrite the underlying value for future frames. Each frame is independent.
You have to either calculate the cumulative values of each frame in your expression (so frame 0 calculates the value for frame 0, frame 1 calculates the values for frames 0 and 1, frame 2 calculates the values for frames 0, 1 and 2, etc.), or you have to think of another way to make your expression a function of time.