Activity › Forums › Adobe After Effects Expressions › Control loop with slider
-
Control loop with slider
Posted by Vinícius Moia amaro on January 28, 2015 at 2:27 pmI have animated pre comp to loop, but i need control how many times be looped with slider control. For example: If slider control value is 4 then pre comp is looped 4 times and stop. Is that possible ?
Vinícius Moia amaro replied 11 years, 7 months ago 2 Members · 5 Replies -
5 Replies
-
Dan Ebberts
January 28, 2015 at 2:40 pmYou 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 pmHi Dan, thanks for help me.
This code work perfectly.
Thanks very much
-
Vinícius Moia amaro
January 28, 2015 at 5:23 pmI 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 pmYeah, 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 pmHi 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.
Reply to this Discussion! Login or Sign Up