views:

144

answers:

2

I want to create a text box with a fixed width that will fit itself to its current text. So I went ahead and wrote this simple application:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="load();">
<mx:Script>
 <![CDATA[
  private function load():void {
   text1.height = text1.textHeight;
  }
 ]]>
</mx:Script>
 <mx:TextArea id="text1" x="10" y="10" width="352" height="196" wordWrap="true" text="Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test"/>
</mx:Application>

Alas, the height of textHeight is twice the height I needed.

How come? and how can it be fixed?

+1  A: 

Here is a link that will help. http://idletogether.com/automatically-resize-texttextarea-based-on-content-autosize-in-flex/

Joey Blake
+1 worked like a charm (thou the posted solution implemented in the above example could've been sweeter).
Eran Betzalel
A: 

Its a bug!

Heres a workaround: http://www.nbilyk.com/flex-textheight-bug

greg