Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Value changes a few frames before it’s supposed to

  • Value changes a few frames before it’s supposed to

    Posted by David Cabestany on August 14, 2019 at 9:01 pm

    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

    David Cabestany replied 6 years, 11 months ago 2 Members · 7 Replies
  • 7 Replies
  • Dan Ebberts

    August 14, 2019 at 9:21 pm

    Hard to say without seeing it, but I’d check this:

    t.sourceRectAtTime(time-t.inPoint,false);

    Why do you have t.inPoint in there?

    Dan

  • David Cabestany

    August 14, 2019 at 9:26 pm

    Hey Dan,

    The text layer does not start at the beginning of the composition, I added that so the layer didn’t start showing at the very first frame.
    I just removed it to test and the problem worsens, now the size increases to the second value the moment it hits the first marker.

    I can send you the file if you don’t mind looking at it.

    Thanks,

  • David Cabestany

    August 14, 2019 at 9:35 pm

    I managed to solve it by adding .1 to the inPoint, but I can’t understand why.
    If you can explain why is happening it’s be greatly appreciated.

    t = thisComp.layer("xp").effect("Layer Control")("Layer");
    margin = thisComp.layer("xp").effect("margin")("Slider");
    r = t.sourceRectAtTime(time-(t.inPoint+.1),false);
    w = r.width*t.scale[0]/100 + margin;
    h = r.height*t.scale[1]/100 + margin/2;
    [w/width,h/height]*100

  • Dan Ebberts

    August 14, 2019 at 9:48 pm

    I’d have to see it, but you probably just need to compensate for have the text layer’s startTime not at time = 0.

    Dan

  • David Cabestany

    August 15, 2019 at 1:11 pm

    I think is that too, but can’t understand why the frames since the layer begins several more frames after.

    Can I send you the file? I have your email already.

  • Dan Ebberts

    August 15, 2019 at 1:39 pm

    Sure.

    Dan

  • David Cabestany

    August 30, 2019 at 4:04 pm

    I think this expression (sourceReactAtTime) is either broken or not quite ready to be included with AE.
    I’m getting all sorts of unwanted jumps and resizes even after I compensated for the in point of the layer. It’s been more of a hindrance than a helper.

    Reporting a bug to adobe, once an easy task, it’s now useless with their new “forum” format.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy