2 Replies Latest reply on May 16, 2009 4:32 PM by Michael Borbor

    How to set variable length of a TextArea?

    hsfrey Level 1

      I would like to set the width of a TextArea and have the length automatically adjust to the amount of text I put in it, avoiding the insertion of a scrollbar.

      I've been unable to find the question answered in either the documentation or the forum archives.


      I read somewhere that if I set the width to an absolute number and omitted the height, that would do the job, but it doesn't. It just gives me a TextArea 2 lines high with a scrollbar. (And, I'd prefer to use widths as percents, if possible).


      Here is the sample code using just absolute heights:


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="loadXML()" >

      <mx:Script>     <![CDATA[
               var xmlData:XML;
              var urlLoader = new URLLoader();

      private function loadXML():void
          {    urlLoader.addEventListener(Event.COMPLETE,onXMLLoaded); urlLoader.load(new  URLRequest("../data/paralog.xml"));    }

      function onXMLLoaded(e:Event):void{  xmlData =  new XML(e.target.data); }
           ]]> </mx:Script>
          <mx:Panel title="{xmlData.title.toString()}" height="400" width="600" layout="vertical"
              horizontalAlign="center" status="status area" >


          <mx:TextArea width="200"
              + '&lt;br&gt;' + xmlData.detail.date.toString()}"


          <mx:VBox width="500" borderStyle="solid" paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10"   >
               <mx:TextArea width="200" editable="false"  text="{'Question:' + xmlData.issue.(@id=='i1').question.toString()}"/>
              <mx:HBox width="550" >
                   <mx:TextArea width="200" editable="false"  text="{xmlData.*.claim.(@id=='i1Y').statement.toString()}"/>
                   <mx:TextArea width="200" editable="false"  text="{xmlData.*.claim.(@id=='i1N1').statement.toString()}"/>



      FYI, here's the XML I'm reading in:

      <?xml version="1.0"?>
      <title>DISTRICT OF COLUMBIA et al. v. HELLER</title>
      <docket>U.S. Supreme Court No. 07-290</docket>
      <decision author="AS">MU-07-290.Op.AS.html</decision>
      <dissent author="JS">MU-07-290.Di.JS.html</dissent>
      <dissent author="SB">MU-07-290.Di.SB.html</dissent>

      <issue id="i1">
          Does the 2d Amendment protect an individual right to possess a usable handgun and to use it for traditionally lawful purposes, such as self-defense within the home? 
          <claim id="i1Y" author="AS" textAt="07-290.AS#S18, 07-290.AS#S625"
                          supportedBy="(i1Yg1)" >
              <statement holding="true">Yes. The 2d Amendment protects an individual right to possess firearms and the [District of Columbia]'s total ban on handguns, as well as its requirement that firearms in the home be kept nonfunctional even when necessary for self-defense, violated that right.</statement>
          <claim id="i1N1" author="JS" textAt="07-290.JS#GETTHIS" opposedBy="(i1N1g1)">
              <statement>No. The prefatory clause demonstrates that the 2d Amendment protects only the right to possess and carry a firearm in connection with militia service.</statement>
          <claim id="i1N2" author="SB" textAt="07-290.SB#GETTHIS">