Check out some of the new methods on the Flash 9 TextField object. Some stuff we’ve been dying for for years. Here’s a nice one:
getCharBoundaries(index)
Returns a rectangle that is pretty much the bounding box of the character specified by the index parameter. In other words the first character in the text field would be index 0, etc.
Here’s a really quick, crappy demo of something you could do with that. Needs a lot of work, for example, it pukes if you search multiline text. Actually, it finds the positions fine, just doesn’t handle them correctly. Would be easy to fix, but I was just playing.
Just type in a word in the text (case sensitive) and hit search.
[kml_flashembed movie=”http://www.bit-101.com/flash9/WordSearch.swf” height=”170″ width=”440″ /]
Neat, eh?
’tis indeed sweet
getTextExtent must be weeping in his grave.
It’s amazing!!
Could post the source? plz
Mmmh… how many times would have I sold my soul for that feature?
Exatcly what I needed for a project where the client asked to have text links in a html textfield that link to another page inside the same flash movie! …. unfortunately the project is for flash player 7.
Impressive, yes, most impressive…
Saeed, click the link that says “Source here”
Very nice…
I love this method
Sweet. I have to look into the other new methods now. I’d be embrassed if I wasn’t so proud of some of the hacks I have come up with in the past for even simple text field stuff. — JOR
Nice, however i am not sure if you guys notice that the boundary to be drawn in a funny way when i search for some part of the paragraph wrapping to the next line..
Yup, as I said, “Needs a lot of work, for example, it pukes if you search multiline text. Actually, it finds the positions fine, just doesn’t handle them correctly.”
Sascha, you can use asfunction for that: livedocs link
Hello everyone,
I agree that this is a great and very necessary feature, one I ended up toiling with and banging my head against for our popup links on
The technique I used is abstracted from the textfield, something along the lines of
getRectFromIndex(s:String, tf:TextField, index:Array):Rectangle
Though the ability to get the index of a single character is fundamental, a function that would return an array of rectangles for multiline searches using the return data from getCharBoundaries(), or simply (from,to), (start,length) like parameters would be most useful; surely you’d agree. A sort of analogy to the way substring() or substr() and indexOf() complement each other. I would love to see precision in this function for advanced anti alias textfields, it would be too bad if this were overlooked.
I think it’s necessary to implement rollover/rollout events for text links/buttons as well…
M