I'm new to using expressions in after effects and I've also hardly touched Java before. However using some online tutorials and common sense, I managed to create a lower thirds title graphic yesterday, the java is used to change it's position based on how much text is written inside. The title graphic bleeds off to the left of the screen, so when text is written on it, it moves left or right to match the length of text. I've included the code below.
s =thisComp.layer("Header title"); x = s.sourceRectAtTime(time-s.inPoint,true).width; subl =thisComp.layer("Sub title"); subt = subl.sourceRectAtTime(time-subl.inPoint,true).width; text = Math.max(subt, x) -100; max = 659.4; m = Math.min(max, text); [m, 871]
Where I'm struggling is I want to make this into an animated motion graphic, where the graphic just slides in and out at the right time. However, if there's less text, it's position is further out the frame and it takes longer to slide in - which means that it's out of sync with other parts of the animation. I'm not worried about consistent speed, I just want it to appear in at the same time as it has to match other animations. The only way I can see this happening accurately is by further encoding, where it gets a little beyond me!
I tried animating using
if expressions dependant on the
time function, but this didn't create a transition, the graphic jumped instantly from point to point. I can't find anything on creating keyframes in java either so not sure the best way to do this.
Really appreciate any help to put me on the right track.