Activity › Forums › Adobe After Effects Expressions › force comp to play from the beginning with every checkbox key?
-
force comp to play from the beginning with every checkbox key?
Posted by Taras Kosmachuk on January 24, 2011 at 2:13 pmHi! What expression do I need to use to force comp to play from the beginning with every checkbox key on and stay at 0 frame when checkbox key is off?
Cris Gundermann replied 12 years, 5 months ago 3 Members · 5 Replies -
5 Replies
-
Dan Ebberts
January 24, 2011 at 4:34 pmTry this:
chkBx = effect("Checkbox Control")("Checkbox");if (chkBx.value == 0){
0
}else if (chkBx.numKeys == 0){
time
}else{
n = chkBx.nearestKey(time).index;
if (chkBx.key(n).time > time) n--;
time - chkBx.key(n).time;
}
Dan
-
Cris Gundermann
October 12, 2013 at 12:35 pmhi dan,
thanks for this script (and for all the others i could find here)!
i’m trying to combine this one with another script by you but i can’t get it to work.
it only works with the last condition.i want a comp to play at random intervals but also want it to play when i activate it manually via checkbox.
i guess it must have sth to do with how the keyframes are held,
but when i remove the first part of the second condition and leave it like this:
if (chkBx.value == 1){
n = chkBx.nearestKey(time).index;
if (chkBx.key(n).time > time) n–;
time – chkBx.key(n).time;
}… nothing will change…
i’m not that much into expressions, so i’d be thankful if you could help me out a bit!thanks in advance,
-cris
//============================================
//if activated, play comp at random intervals.
//============================================
minDur = 1;
maxDur = 2;randChkBx = comp("xxx").layer("xx").effect("playRandom")("Kontrollkästchen");
if (randChkBx.value == 1){
seedRandom(index,true);
t0 = inPoint + random(maxDur);
t1 = t0 + random(minDur,maxDur);
while(t1 < time){
t0 = t1;
t1 = t0 + random(minDur,maxDur);
}
t = time - t0;
} else {
value
}//============================================
//if activated, play comp, else hold on 0.
//============================================chkBx = comp("xxx").layer("xx").effect("playNow")("Kontrollkästchen");
if (chkBx.value == 0){
0
}else if (chkBx.numKeys == 0){
time
}else{
n = chkBx.nearestKey(time).index;
if (chkBx.key(n).time > time) n--;
time - chkBx.key(n).time;
} -
Dan Ebberts
October 12, 2013 at 4:53 pmI think you need to nest one of the expressions inside the other. If you wanted the playNow checkbox to have priority, you would do something like this (not tested):
chkBx = comp("xxx").layer("xx").effect("playNow")("Kontrollkästchen");
if (chkBx.value == 0){
minDur = 1;
maxDur = 2;
randChkBx = comp("xxx").layer("xx").effect("playRandom")("Kontrollkästchen");
if (randChkBx.value == 1){
seedRandom(index,true);
t0 = inPoint + random(maxDur);
t1 = t0 + random(minDur,maxDur);
while(t1 < time){
t0 = t1;
t1 = t0 + random(minDur,maxDur);
}
t = time - t0;
} else {
value
}
}else if (chkBx.numKeys == 0){
time
}else{
n = chkBx.nearestKey(time).index;
if (chkBx.key(n).time > time) n--;
time - chkBx.key(n).time;
}
Dan
-
Cris Gundermann
December 11, 2013 at 10:43 amhi,
i totally forgot to reply and thank you.
with your help i could achieve what i was aiming for.
all the best
Reply to this Discussion! Login or Sign Up