Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Control loop with slider

  • Dan Ebberts

    January 28, 2015 at 2:40 pm

    You can build your own loop expression, which you could control with a slider like this:


    s = effect("Slider Control")("Slider");
    if (numKeys > 1){
    n = Math.floor(time/key(numKeys).time);
    if (n < Math.round(s)){
    t = time%key(numKeys).time;
    valueAtTime(t);
    }else{
    key(numKeys).value;
    }
    }else
    value

    Dan

  • Vinícius Moia amaro

    January 28, 2015 at 3:02 pm

    Hi Dan, thanks for help me.

    This code work perfectly.

    Thanks very much

  • Vinícius Moia amaro

    January 28, 2015 at 5:23 pm

    I saw just now, but there is a problem . When I have loop starting at frame 0 the code works perfectly , but if I want to start the loop at another time , for example frame 30, this code add 30 stuck frames before start each loop. There is a way to solve ?

  • Dan Ebberts

    January 28, 2015 at 7:29 pm

    Yeah, that was a little sloppy on my part–sorry (I made some assumptions). This should behave more like loop() does:


    s = effect("Slider Control")("Slider");
    if ((numKeys > 1) && (time > key(numKeys).time)){
    n = Math.floor((time - key(numKeys).time)/(key(numKeys).time-key(1).time));
    if (n < Math.round(s-1)){
    t = (time - key(numKeys).time)%(key(numKeys).time-key(1).time);
    valueAtTime(key(1).time + t);
    }else{
    key(numKeys).value;
    }
    }else
    value

    Dan

  • Vinícius Moia amaro

    January 29, 2015 at 1:40 pm

    Hi Dan

    Thanks for help me .
    The code now work perfectly.

    I realized the other code will also be useful in other things, so no need to worry , I’m very happy with the results.

    Sorry my bad english.

    Thanks very much.

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