Activity › Forums › Adobe After Effects Expressions › interpolation in “if else clause” to be triggered multiple times
-
interpolation in “if else clause” to be triggered multiple times
Posted by Leif Heidenreich on March 16, 2009 at 12:47 pmdear reader of this post…
I am stuck with the following:
if (thisComp.layer(“Work_Radar_Ring Control”).effect(“Sector1”)(“Slider”)< 5) {ease_in(time,0,2,0,100)} else {ease_out(time,0,2,100,0)} Meaning, that the opacity will change once (if trigered by the slider) from Time 0-2 , from 0-100%. But I would like to have a fade in/fade out every time the expression is triggered by the slider over a period of 2 seconds... I hope you can help me out here, The worldwideweb kept its answers from me... regards leif
Leif Heidenreich replied 17 years, 1 month ago 2 Members · 7 Replies -
7 Replies
-
Filip Vandueren
March 16, 2009 at 3:05 pmIf I understand you correctly, when the slider drops below 5, a fade-out is triggered, when it goes above 5, a fade-in is triggered ?
sl=thisComp.layer("Work_Radar_Ring Control").effect("Sector1")("Slider");
threshold=5;fd=thisComp.frameDuration;
t=0;
triggerTime=-100;
crossed=null;// look at all previous frames to find out the last time sl crossed the threshold;
while(time>t) {
if (sl.valueAtTime(t)>=5 && sl.valueAtTime(t-fd)<5) { triggerTime=t; crossed="up"; }
if (sl.valueAtTime(t)<=5 && sl.valueAtTime(t-fd)>5) { triggerTime=t; crossed="down"; }
t+=fd;
}// with each trigger,reset the relative time to 0
// so we can use it in the ease interpolation
relative_time=time-triggerTime;if (crossed=="up") {
ease_in(relative_time,0,2,0,100);
} else if (crossed=="down") {
ease_in(relative_time,0,2,100,0);
} else {
0; // default value
}
-
Leif Heidenreich
March 16, 2009 at 3:44 pmyou pinpointed my problem.
The relative time aspect is the key.works flawless.
Thank you very much…
-
Leif Heidenreich
March 19, 2009 at 11:59 amsl=thisComp.layer("Work_Radar_Ring Control").effect("Sector 1")("Slider"); threshold=5; fd=thisComp.frameDuration; t=0; triggerTime=-100; crossed=null; // look at all previous frames to find out the last time sl crossed the threshold; while(time>t) { if (sl.valueAtTime(t)<=threshold && sl.valueAtTime(t-fd)>threshold) { triggerTime=t; crossed="up"; } if (sl.valueAtTime(t)>=threshold && sl.valueAtTime(t-fd)Hi Filip, salut everyone,
Is it possible, that due to the script rendering times increase allmost exponential.
0:00:00:00 (1): 3 Seconds
0:00:01:00 (31): 2 Seconds
0:00:02:00 (61): 3 Seconds
0:00:03:00 (91): 3 Seconds
0:00:04:00 (121): 4 Seconds
0:00:05:00 (151): 5 Seconds
0:00:06:00 (181): 5 Seconds
0:00:07:00 (211): 6 Seconds
0:00:08:00 (241): 8 Seconds
0:00:09:00 (271): 7 Seconds
0:00:10:00 (301): 9 Seconds
0:00:11:00 (331): 9 Seconds
0:00:12:00 (361): 9 Seconds
0:00:13:00 (391): 10 Seconds
0:00:14:00 (421): 11 Seconds
0:00:15:00 (451): 11 Seconds
0:00:16:00 (481): 12 Seconds
0:00:17:00 (511): 12 Seconds
0:00:18:00 (541): 13 Seconds
0:00:19:00 (571): 14 Seconds
0:00:20:00 (601): 15 Seconds
0:00:21:00 (631): 16 Seconds
0:00:22:00 (661): 16 Seconds
0:00:23:00 (691): 17 Seconds
0:00:24:00 (721): 18 Seconds
0:00:25:00 (751): 18 Seconds
0:00:26:00 (781): 19 Seconds
0:00:27:00 (811): 19 Seconds
0:00:28:00 (841): 20 Seconds
0:00:29:00 (871): 21 Seconds
0:00:30:00 (901): 21 Seconds
0:00:31:00 (931): 22 Seconds
0:00:32:00 (961): 23 Seconds
0:00:33:00 (991): 26 Seconds
0:00:34:00 (1021): 23 Seconds
0:00:35:00 (1051): 28 Seconds
0:00:36:00 (1081): 25 Seconds
0:00:37:00 (1111): 30 Seconds
0:00:38:00 (1141): 31 Seconds
0:00:39:00 (1171): 28 Seconds
0:00:40:00 (1201): 34 Seconds
0:00:41:00 (1231): 57 Seconds
0:00:42:00 (1261): 1 Min, 14 Sec
0:00:43:00 (1291): 1 Min, 13 Sec
0:00:44:00 (1321): 1 Min, 27 Sec
0:00:45:00 (1351): 1 Min, 19 Sec
0:00:46:00 (1381): 1 Min, 24 Sec
0:00:47:00 (1411): 1 Min, 55 Sec
0:00:48:00 (1441): 1 Min, 29 Sec
0:00:49:00 (1471): 1 Min, 27 Sec
0:00:50:00 (1501): 4 Min, 24 SecThe Script is used on 40 Sectors, which fade in and out, triggered by the script.
I assume that over time the script seems to recalculate previous processes.
Any Idea where this problem could evolve from?
Regards
Leif -
Filip Vandueren
March 20, 2009 at 3:55 amYes, that’s the absolute downside of this method, all frames have to be recalculated, so the longer your comp, the longer it takes on each frame.
Once you’re okay with animating your slider and the result of the expression, you’re best off to “convert the expressions to keyframes”: that takes some time too, but afterwards you can then tweak other things in your comp, without loosing time waiting for these expressions.
-
Leif Heidenreich
March 20, 2009 at 1:28 pmI liked to keep things dynamic to a certain level.
Wouldnt it be possible to just check back the last so and so many seconds to gateher the necessary information?
Isnt there anyway to bypass the recalculation of the whole framedruation?
But certainly this expression made me read a lot about javascript, since I still seem not to be able to comprehend the big picture…
I thought it would be enough, to have the expression check the valueAtTime and than trigger the ease in/out…
Like:
If the value is >= 5 ease in over 1 second from 0 to 100 and stay
unless
the value is <= 5 than ease out over 1 second form 100 to 0 and stay thanks leif -
Filip Vandueren
March 20, 2009 at 8:01 pmYes, but in actionscript, there’s no such thing as triggering an animation.
The result of an expression is always the value for that property on this frame.In your case we could limit the “looking back” to only the last few seconds (as long as the ease would take) to know if a ‘crossing the threshold occured), and if no crossing occured, just use 100 when >5 and 0 when <0
sl=thisComp.layer(“Work_Radar_Ring Control”).effect(“Sector1”)(“Slider”);
threshold=5;animTime=1;
fd=thisComp.frameDuration;
t=time-animTime;
triggerTime=-100;
crossed=null;// look at all previous frames to find out the last time sl crossed the threshold;
while(time>t) {
if (sl.valueAtTime(t)>=5 && sl.valueAtTime(t-fd)<5) { triggerTime=t; crossed="up"; }
if (sl.valueAtTime(t)<=5 && sl.valueAtTime(t-fd)>5) { triggerTime=t; crossed=”down”; }
t+=fd;
}// with each trigger,reset the relative time to 0
// so we can use it in the ease interpolation
relative_time=time-triggerTime;if (crossed==”up”) {
ease_in(relative_time,0, animTime,0,100);
} else if (crossed==”down”) {
ease_in(relative_time,0, animTime,100,0);
} else {
threshold>sl ? 100 : 0;
}
I have not tested this though
-
Leif Heidenreich
March 22, 2009 at 11:00 pmExactly, that works very well render wise.
I get a sideeffect though, maybe not due to your last alteration.
When the value stayed above the threshold and than falls below it, in some occasions the value flips from 0% to 100% for 1 Frame, and falls back to 0% then.
(or the other way around)I havent found a clue yet, accept that the triggertime seems to be involved…
Could u explain the triggertime aspects to me… I am still confused about its value…
thanks for your enhancements…
Reply to this Discussion! Login or Sign Up