-
Looping within Ebberts’ marker-driven animation
Hi,
I couldn’t find an answer to this anywhere else so I figured I’d register to ask the question here. I’m using Dan Ebberts’ fantastic “Triggering Animation with Markers” example from motionscript.com. The way it works though is that when reaching the end of an action marker’s ‘segment’ it simply stops on the last frame before the next action marker.
The change I’d like to make I think is pretty simple, which is simply to loop back to the current action marker’s time and play out its ‘segment’ again. Ping-pong would be cool too. I’m just not sure how exactly that bit of the expression works and I’m hoping someone cleverer than I can figure it out. 😉
Thanks in advance!
Here’s the code from Dan’s site for reference:
action = comp(name).layer("action");n = 0;
if (marker.numKeys > 0){
n = marker.nearestKey(time).index;
if (marker.key(n).time > time){
n--;
}
}if (n == 0){
0
}else{
m = marker.key(n);
myComment = m.comment;
t = time - m.time;
try{
actMarker = action.marker.key(myComment);
if (action.marker.numKeys > actMarker.index){
tMax = action.marker.key(actMarker.index + 1).time - actMarker.time;
}else{
tMax = action.outPoint - actMarker.time;
}
t = Math.min(t, tMax);
actMarker.time + t;
}catch (err){
0
}
}