ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Add expression that only affects first keyframe

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Will Bartlett
Add expression that only affects first keyframe
on Aug 5, 2019 at 2:32:45 am

Hi!

I have a lower thirds title and I've setup an expression so that the shape layer automatically changes the width to match whatever length the text layer is:

dFirst=thisComp.layer("TOP TEXT").sourceRectAtTime(time).width;

value+[dFirst,0]*thisComp.layer("TOP TEXT").transform.scale[0]/100


It works great, except I have 2 position keyframes for animating the shape layer from off screen to on screen. If the text layer has too many characters, the first keyfame ends up being pull onto the screen because the entire shape layer is being moved by the expression.

Is there an expression I can add that will only affect the first keyframe so that it no matter what will keep a value that is off screen for the first frame in the composition?

And as a bonus I've copied and pasted the two keyframes to the end of the comp as well, then time reversed them so that the lower thirds exits the frame in the same way. If the expression would work for the last key frame to be off screen, that would be great!

Any help would be appreciated!

Thank you!


Return to posts index

Andrei Popa
Re: Add expression that only affects first keyframe
on Aug 5, 2019 at 7:12:35 am

I suggest you separate position dimensions(right click on position>Separate Dimensions).
I don't know how your shape layer looks like(how its anchor is positioned etc) so this is an aproximation of what you will need. You need to calculate the newValue by yourself(this depends on where the anchor point is). I assume your key 2 and key 3 have the same value. If so, this is the expression you put in the x property of position

newValue = - sourceRectAtTime(time).width;
time2 = key(3).time;
if(time <key(3).time){
linear(transform.xPosition,key(1).value, key(2).value, newValue, key(2).value)
}else{
linear(transform.xPosition,key(3).value, key(4).value, newValue, key(3).value)
}


Andrei
My Envato portfolio.


Return to posts index

Will Bartlett
Re: Add expression that only affects first keyframe
on Aug 5, 2019 at 7:16:21 am

Thank you for your reply and for the suggestions!

The shape layer has the anchor set to the left middle side (So it can expand to the right).

Yes, key 2 and key 3 are the same.

Will try this out, thanks!


Return to posts index


Andrei Popa
Re: Add expression that only affects first keyframe
on Aug 5, 2019 at 7:20:36 am

If the anchor point is not set there by expression, it will move when you make the rectangle bigger. Put this expression in the anchorpoint, in case you don't already have one:


var left = sourceRectAtTime(time,false).left;
[left,value[1]]


Then, the previous expression should work as it is.

Andrei
My Envato portfolio.


Return to posts index

Will Bartlett
Re: Add expression that only affects first keyframe
on Aug 5, 2019 at 4:55:21 pm

Ok, Thank you! Appreciate it


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]