is it possible to move an layer if something happens, for example, when my solid is higher than wide, layer 2 should move from p1 to p2 and vice versa. i coded something like that, but its not moving on the event.
From the looks of it you're attempting to apply the expression to time remapping. That could be done, I guess, but it would make more sense to apply an expression to the layer position.
What the problem with your current expression is, is that the linear expression is trying to remap the first second of time (0-1) on the timeline to a "range" between two keyframe objects, which basically doesn't make much sense.
Now, since expressions are not aware of time, you need a loop to check backwards (or forwards or both) from the current frame for past and future values, frame by frame.
For instance, in order to find out how many frames ago the value changed from H>W to H
Senior Graphic Designer