# Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Start Linear Expression at certain time, play it once and hold at end result

• # Start Linear Expression at certain time, play it once and hold at end result

2 Members · 4 Posts
• ### Tim Johnson

March 3, 2020 at 6:00 pm

Hi!

I’m trying to get a linear expression to play (typing on text) when one value equals another.

So, in my expression, I want the animation to start at the frame where x is equal to y. Then play it through once and hold it at the end result for the rest of the comp.

Here’s what I’ve got so far:

` x = thisComp.layer("Text").effect("Type_on")("Slider").valueAtTime(time); y = thisComp.layer("Text").text.sourceText.length; z = timeToFrames(time) length = text.sourceText.length; typeOn = linear(time, x == y, (x == y)+1, 0, length); `

Not too sure how to proceed. Obviously the time brackets of the linear field is wrong but I left it in to give an idea of what I’m trying to do.

Thanks in advance for any help 🙂

• ### Alex Printz

March 3, 2020 at 7:49 pm

Im a little confused, what is supposed to be driving what here?

You’re trying to start an animation when something else equals something else in time? What if x becomes greater than Y, or vice versa?

Here is an inline if operator, that sets typeOn equal to 0 unless x equals y, then it begins to linear in time from x to x+1, outputting 0 to length.

`x = thisComp.layer("Text").effect("Type_on")("Slider"); y = thisComp.layer("Text").text.sourceText.length; z = timeToFrames(time); length = text.sourceText.length;`

`typeOn = (x==y ? linear(time, x, x+1, 0, length) : 0);`

Alex Printz
Mograph Designer

• ### Tim Johnson

March 4, 2020 at 9:59 am

Hey Alex, thanks very much!

So the animation triggers once x == y. It doesn’t matter if it goes higher, because it’s already played the animation.

Basically I’m making a template where the bottom line of text is underlined by a shape layer which stretches to fit it depending on how many characters there are.

I’ve used split() to output the last line into a new layer which is used by the shape layer via sourceRectAtTime.

The last issue is the type on – i need the last line’s type on animation to trigger once the rest of the text has finished typing on.

So the when (time) the amount of characters in the type on reveal (x) matches the amount of characters in the source text it’s revealing (y), the type on of the last line is triggered.

Hope that makes sense! It’s been so convoluted to get it to this point, I can’t give up now… have learned a lot about expressions in the process though ☺

I tried your inline expression by the way, it just seems to flash the first letter of the last line once x == y.

• ### Alex Printz

March 5, 2020 at 6:30 pm

I think I understand what you’re trying to do, but I don’t understand how it fits in as a whole or what is driving what. How is your animation running? Are you keyframing it, running it through time (and if so, what is changing and what are the parameters)? What slider is your master control?

Linear is not a trigger, it’s a proportion scale, so it will have to be constantly calculating every frame, unless you have a trigger outside of this expression that you’re not describing here.

Alex Printz
Mograph Designer

Viewing 1 - 4 of 4 posts