![]() |
![]() |
||||||
|
|||||||
| Tags: |
![]() |
|
|||
|
Hi!
I have a mx:Text component with a specified width. On every change of the text property in this Text component the height should be updated to fit the whole text. How is that possible? Anyone knows a work-around with other classes? When I try following... --------------------------- myText.text = "targettext, can grow multiline"; myText.height = myText.textHeight; --------------------------- ... the height property changes, however always too late (on the next programmturn). change="updateMyText()" in the .mxml also haven't worked. Eventlistener on FlexEvent.DATA_CHANGE won't get called. validateNow() haven't worked. I'm very tired of this problem and hope, someone can help me. mfg Tschouba |
| Sponsored Links |
|
|||
|
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? <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Script> <![CDATA[ import mx.events.FlexEvent; private function buttonClickHandler(event:MouseEvent):void { text1.text = "Hello World...Lorem ipsum dolor sit amet, " + "consectetur adipisicing elit, sed do eiusmod tempor " + "incididunt ut labore et dolore magna aliqua."; } ]]> </mx:Script> <mx:Text id="text1" x="323" y="157" text="Hello World" width="156" opaqueBackground="0x00ff00"/> <mx:Button id="button1" x="368.5" y="264" label="Button" click="buttonClickHandler(event)"/> </mx:Application> |
|
|||
|
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 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! Greets, Tschouba |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
- Contact Us
-|-
Adobe Dreamweaver Forums -|-
Archive -|-
Top -|-Rules/Disclaimer-|-Help/Support-|-Advertise