-
AE computes expression wrongly
Hi All,
I’ve been trying to create an algorithm which randomly selects either 100% or 0% opacity with weighting based on the previous few frames. I’ve tested this in a javascript environment (see https://mootools.net/shell/pNagf/) and it works as it should. When I use it as an AE expression, AE just gives me 100% opacity the whole way through which is a real pain because there are no code debugging tools in AE.
Any ideas what may be wrong? I need this fairly urgently.P.S.: It’s meant to do it every two frames which is the reason for the modulo operation at the beginning.
var score = 0;
var incr = 0.25;
var setTo = (time > 1) ? opacity.valueAtTime(time-2) : 1;if(time%2 == 0 && time > 2) {
score = incr;if(time > 4 && opacity.valueAtTime(time-4) == opacity.valueAtTime(time-2)) {
score = score + incr;if(time > 6 && opacity.valueAtTime(time-6) == opacity.valueAtTime(time-4)) {
score = score + incr;if(time > 8 && opacity.valueAtTime(time-8) == opacity.valueAtTime(time-6)) {
score = score + incr;
}
}
}var change = (random(200)/100 - 1) + score;
if(change > 0.5) {
setTo = (opacity.valueAtTime(time-1) == 1) ? 0 : 1;
} else {
setTo = (opacity.valueAtTime(time-1));
}
} else {
setTo = (time > 1) ? opacity.valueAtTime(time-1) : 1;
}setTo;