-
Value changes a few frames before it’s supposed to
I’m using a text layer to drive the size of a background box using sourceRectAtTime.
The text is driven by an expression that updates the value using the comment inside the markers, much like using hold keyframes but I do not need to drag them.The box adjusts its size to the corresponding dimensions three frames before the marker is reached. I do not understand why. Can anyone help me understand?
Thanks.
Expresion for the text layer:txt = value;
n = 0;
if (thisComp.marker.numKeys > 0){n = thisComp.marker.nearestKey(time).index;
if (thisComp.marker.key(n).time > time) n--;
if (n > 0) txt = thisComp.marker.key(n).comment;
}
txt;
-----------
Expression for the scale of the box:t = thisComp.layer("xp").effect("Layer Control")("Layer");
margin = thisComp.layer("xp").effect("margin")("Slider");
r = t.sourceRectAtTime(time-t.inPoint,false);
w = r.width*t.scale[0]/100 + margin;
h = r.height*t.scale[1]/100 + margin/2;
[w/width,h/height]*100