I have a text field within Flash that contains a block of (obviously) text.
What I want to do is perform a search on the content of the text field that returns the x & y coordiante and the width & height of the found text. The result will be used to place a visual element over that portion of the text box.
For example:
var pattern:RegExp = /\d+/g;
var found:Array = box.text.match(pattern);
var i:String;
for each(i in found)
{
/**
* Find the x, y, width, height of the matched text in the text field
* Use result to place transparent yellow box around text
*/
}
Which visually should result in something like:

You would want to make use of the TextField class’s
getCharBoundariesmethod, which accepts character indexes and returns a Rectangle object.As far as I know, your
matchmethod returns the strings themselves, so first you’ll probably need to use the String class’sindexOfmethod, find all your character indexes, pass them to thegetCharBoundariesmethod, then draw some rectangles based on that output.Here’s some reference.
Good luck!