R – A real drawText call in Flex

actionscript-3apache-flex

I am now developing a Flex application in which I need to control each pixel of my control of Flex. I want to calculate that how width and how height of some text used in my control and do some layout stuff.After some searching I find that the only way to draw text in Flex is to use something like TextField. So, I use TextField to display text and try to get the width and height of the text through:

textfiled.getLineMetrics(0).width/.height;

But the real textfield is much more bigger than this, so I do:

textfield.width = textfiled.getLineMetrics(0).width;
textfield.height = textfiled.getLineMetrics(0).height;

But, the textfield get part not displayed, and I am surprised by this effect. I know there should be a 2-pixel gutter around the text, but what the remain space? Why nearly 20% part of the text height/width are not displayed?

And how can I get a real drawText call in Flex, I mean something like Windows's drawText method…

Thanks!

Best Answer

you can try this : getCharBoundaries () i've used it and seems accurate hoever it is for char and not a whole text so you will need to iterate through the text

also see this :

Is there a way to get the actual bounding box of a glyph in ActionScript?

Related Topic