Adobe Flex 4 text height

2019-08-29 06:33发布

问题:

I remember in Flex 3 text width/height could be calculated (not the text UI component but the text itself):

new Text().textHeight; 

or

new Text().getTextField().measuredHeight;

Does anyone know how can that be done in Flex 4 with its Text Layout Framework now?

Thanks.

回答1:

I've found an answer myself. If someone has any better ideas - you're welcome.

I use to assume that width of text content is not so important cause each time the size changes the value used below are updated. So I check the height of text (assuming width is fixed) as:

var textHeight: Number = (_text.textLines.length-1) * _text.textFlow.lineHeight + _text.textFlow.fontSize

where _text is s:RichText.

I needed to know whether the text inside did not exceeded the space available, that's why the only thing I need now is to check whether textHeight < _text.height That's it. Be sure the text is rendered correctly before checking the height (I use to listen to UDPATE_COMPLETE event).



标签: flex4