I love digging through the class files in Flash MX 2004.
You find neat little tidbits like getTextExtent2, where it is admitted that TextFormat.getTextExtent is broken in Flash.
The solution? They create an invisible text field on _root, at a depth of -2. Assign it the text and the format in question, autosize it, measure its resulting textWidth and textHeight and return that.
Thats all in classes/mx/core/ext/UIObjectExtensions.as
🙂
They think they’re sooo smart…
i saw that too… been using the same technique for a while since text extend didnt work too well… and is slow… another application of the same method would be to add ellipsis to text based on the size of the textfield (and if it resizes) adding text to an existing textfield and checking its width/height properties is way faster that using text extent… esp in a for loop . time was 8 ms to 40 ms
nik