I have a type effect that requires a couple of layers, one with the type, and another moving behind the letters as they appear (simulating the little text bubbles you get when typing on an iPhone). It's very tedious animating the position of the bottom layer to match the text, so I'm wondering if it's possible to use any javascript tools to measure the characters and drive the position value.
Currently I have an expression driving the opacity like this, to automatically turn the background off for spaces:
theOffset=thisComp.layer(1).text.animator("Animator 1").selector("Range Selector 1").offset;
if (thisComp.layer(1).text.sourceText.substr(theOffset, 1) == " " ){0} else {100}
and another that folows the text animator range selector so that I can retime if I want without having to nudge keyframes till doomsday:
theOffset=thisComp.layer(1).text.animator("Animator 1").selector("Range Selector 1").offset;
try {
transform.position.key(theOffset + 1).value
}
catch(error){[-10000,0]}//effectively hide it on errors (like the index going out of bounds)
…but this relies on me going through and creating keyframes to match the spacing of all the letters in the text, and frankly I'd rather be doing something else with the time that takes. so I'm trying to find a string method that I could use like this:
xOffset = thisComp.layer(1).text.sourceText.substr(1, theOffset).getTextWidth()
but getTextWidth obviously isn't a valid method. Is there a JS method that can get the size of a string on screen? There seems to be several solutions for this when the client is a web browser, but I can't find any that work for AE expressions.