We are trying to get a Rectangle that represents the exact * border of text in a TextField .
** As accurate as possible. *
Take this image:

Using my current knowledge, I can extract the blue rectangle above:
var textRect:Rectangle = new Rectangle( field.x, field.y, field.textWidth, field.textHeight );
However, we need to get as close as possible to the red rectangle (I understand that there will be slight differences, because the characters change with / height, and there should be a common base).
How can I get a red rectangle (dynamically)?
I installed this helper class based on the answer below, Jacob Eggers, however I always get the result (x=0, y=0, w=0, h=0) ..
package { import flash.display.BitmapData; import flash.text.TextField; import flash.geom.Rectangle; public class TextBounds { public static function getTextBounds(textField:TextField):Rectangle { var curtainColor:uint = 0x00FF00; var bmd:BitmapData = new BitmapData(textField.width, textField.height, false, curtainColor); bmd.draw(textField); return bmd.getColorBoundsRect(curtainColor, textField.textColor, true); } } }
Even if I fill the small section with the color I'm looking for, I still get a zero-sized rectangle:
bmd.fillRect(new Rectangle(0, 0, 30, 30), textField.textColor);