I just want to understand better what you are after. Why do you need easing before and after keyframe? Wouldn’t it be enough to ease after the keyframe like this: after checkbox off, ease to zero. After checkbox on, ease to one. That way, you can get both in and out animations. You must be careful not to put consequent keyframes with the same value. When this expression finds a “ON” keyframes, goes from 0 to 100 even if the value was 100 before the keyframe.
If that suits your case, this could be the expression:
fadeTime = 0.5;
cb = thisComp.layer("Controller").effect("Timer ON")("Checkbox");
if (cb.numKeys > 0) {
n = cb.nearestKey(time).index;
if (cb.key(n).time > time) n--;
if (n > 0) {
t = time - cb.key(n).time;
if (cb.key(n).value > 0) ease(t, 0, fadeTime, 0, 100);
else ease(t, 0, fadeTime, 100, 0);
} else {
cb.key(1).value == 1 ? 0 : 100;
}
} else cb.value > 0 ? 100 : 0;
Andrei
My Envato portfolio.