FORUMS: list search recent posts

Control loop with slider

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Vinícius Moia Amaro
Control loop with slider
on Jan 28, 2015 at 2:27:08 pm

I 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 ?


Return to posts index

Dan Ebberts
Re: Control loop with slider
on Jan 28, 2015 at 2:40:53 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



Return to posts index

Vinícius Moia Amaro
Re: Control loop with slider
on Jan 28, 2015 at 3:02:55 pm

Hi Dan, thanks for help me.

This code work perfectly.

Thanks very much


Return to posts index


Vinícius Moia Amaro
Re: Control loop with slider
on Jan 28, 2015 at 5:23:56 pm
Last Edited By Vinícius Moia Amaro on Jan 28, 2015 at 5:28:43 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 ?


Return to posts index


Dan Ebberts
Re: Control loop with slider
on Jan 28, 2015 at 7:29:58 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



Return to posts index

Vinícius Moia Amaro
Re: Control loop with slider
on Jan 29, 2015 at 1:40:05 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.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]