Forums › Adobe After Effects Expressions › Slider Control Incrementing up Every Marker
-
Slider Control Incrementing up Every Marker
-
Mark Quinones
June 21, 2022 at 3:40 pmHello, I’m working on an expression that moves a Slider Control up by 40 every time the playhead passes a marker, it’s incrementing up every marker like I want but the linear I’m using doesn’t work, the slider goes up the full amount in 1 frame instead of over half a second like I would expect, what might be causing this?
var moveTime = .5; var moveAmount = 40; if (thisLayer.marker.nearestKey(time).time < time) { markerCount = thisLayer.marker.nearestKey(time).index + 1; } else markerCount = thisLayer.marker.nearestKey(time).index; //Returns the index of the marker ahead of the current time var moveStart = thisLayer.marker.key(markerCount).time; if (time = moveStart) { scroll = linear(time, moveStart, moveStart + moveTime,(markerCount-1)*moveAmount,markerCount*moveAmount); } scroll;
-
Dan Ebberts
June 21, 2022 at 4:23 pmI’d do it like this:
moveTime = .5;
moveAmount = 40;
m = marker;
scroll = 0;
if (m.numKeys > 0){
n= m.nearestKey(time).index;
if (time < m.key(n).time) n--;
if (n > 0){
t = time - m.key(n).time;
scroll = (n-1)*moveAmount + linear(t, 0, moveTime, 0, moveAmount);
}
}
scroll
-
Mark Quinones
June 21, 2022 at 4:38 pmThis worked perfectly, thanks for your help.
Viewing 1 - 3 of 3 posts
Log in to reply.