The height of mx.controls.Text should be adjusted automatically when text is assigned. If you assigned a function to the dataChange property, then that will fire off an event (FlexEvent.DATA_CHANGE) to that assigned function when the *data* property of Text gets assigned a value. The data property takes an Object type for its value.
Thanks for your reply!
The height of the mx.controls.Text gets only adjusted automatically, when I set the text property in the .mxml file on initialize (<mx:Text text="myText" />).
But I want to change the text dynamically while the program flow with myText.text="myNewText". Then the height should be adjusted to fit the whole new text.
Can I use the data property to display the text?
The data property is designed to be used when a Text instance is implemented as an item render or for data binding. So as always when troubleshooting, limit the amount of variables to the equation.
Below is a minimalist example of a Text instance that will get its height adjusted when a Button is clicked.
Does this help?
You're right, the height gets adjusted automatically in your example.
However, in my target programm it wasn't so, althougt it was the same text-component-code as in yours.
So again I tried around and finally I found my error: At the canvas tag (that was surrounding the Text component) autoLayout was set to false. Because of that the height of the text inside wasn't adjusted automatically.
autoLayout="true" --> all works fine
Thanks for your help, myIP!