-
Percentual progress, in time, between previous and the next keyframe issue
Hi folks,
New to expressions, I’d like to calculate the percentual progress, in time, between previous and next keyframe. The ’p’ value below seems to return the accurate result, at first. Then the numbers goes red and I get this error message:
”After Effects warning: an expression was disabled as a result of an error.
Error at line 0 in property ’Position’ of layer 11 (’test layer’) in comp ’test’.
invalid numeric result (divided by zero?).”Why, anyone? It was not divided by zero as the error message suggests.
Thanks,
MikaelnearKey = thisLayer.position.nearestKey(time).index;
lastKey = (thisLayer.position.key(nearKey).time>time) ? ((nearKey>1) ? nearKey-1 : nearKey) : nearKey;
nextKey = (lastKey<thisLayer.position.numKeys) ? lastKey+1 : lastKey;lastTime = timeToFrames(thisLayer.position.key(lastKey).time);
nextTime = timeToFrames(thisLayer.position.key(nextKey).time);durationInFrames = nextTime-lastTime;
progressInFrames = timeToFrames(time)-lastTime;
progress = progressInFrames/durationInFrames;p = (progressInFrames/durationInFrames)*100;
[p, p]