Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Looping within Ebberts’ marker-driven animation

  • Looping within Ebberts’ marker-driven animation

    Posted by Danny Askew on June 29, 2011 at 11:15 pm

    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
    }
    }

    Danny Askew replied 15 years, 2 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    June 29, 2011 at 11:49 pm

    I don’t have time to test this out, but I think you should be able to replace this line:

    t = Math.min(t, tMax);

    with this one:

    t %= tMax;

    Dan

  • Danny Askew

    June 29, 2011 at 11:55 pm

    Brilliant as always! Works perfectly! Thanks!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy