3 Replies Latest reply on Jan 15, 2009 9:53 AM by Mainmanian

    Expandable TextArea

      In a component that I am designing, I have a query result that is coming from a database that may be one line or twenty lines. I have two such queries one after the other and I would like to place them one below the other without scroll bars.

      Can I use TextArea in a way that expands depending upon the text? Is there any other way to do this. Thanks, Ramesh
        • 1. Re: Expandable TextArea
          rtalton Level 4
          Use percentage-based height/width properties (100% & 100%) on the textAreas, and place them in a VBox container.
          • 2. Re: Expandable TextArea
            Mainmanian Level 1
            Thanks for the thought. I did think of that. However (must be due to my newness to programming), as my design is sorta ad-hoc, when I use VBox, I feel like, I am constantly going back and trying to rearrange stuff on the page. I think you are right though. That may be my only option. Thanks again. You are an asset to the forum. Cheers, Ramesh
            • 3. Re: Expandable TextArea
              Mainmanian Level 1
              I have below a code snippet that extends TextArea and effectively changes its behavior as it relates to textHeight. It works well for regular text, but does not work for htmlText. Can some one help with the htmlText part? The snippet was written by Mayur and was posted in Nabble flex forum. There is a line that is commented out that seems to be an effort that did not work. Any help is appreciated.

              package test.util
              import mx.controls.TextArea;
              import flash.events.KeyboardEvent;
              import flash.events.TextEvent;
              import mx.states.SetStyle;

              public class AutoResizingTextInput extends TextArea
              public var my_height:Number;
              public var my_width:Number;
              private var __realText:String;

              public function AutoResizingTextInput()
              this.addEventListener(TextEvent.TEXT_INPUT, textInputHandler);
              /* setStyle(”borderStyle”,”solid”); */
              public function set realText (str:String):void {
              __realText = str;

              public function get realText ():String {
              return __realText

              override public function set htmlText (str:String):void {

              protected function textInputHandler(event:TextEvent = null):void

              override protected function keyDownHandler(event:KeyboardEvent):void

              override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
              super.updateDisplayList(unscaledWidth, unscaledHeight);
              this.height = this.textField.textHeight+10;
              my_width = this.textField.textWidth
              this.textField.scrollV = 0