1 Reply Latest reply on Jan 7, 2010 1:39 PM by Woodifer01

    Dynamically resize a text component


      I am trying to build a simple twitter application.  I pull in the feed from twitter and set it to an arrayCollection.  This information is passed to a list component as a dataProvider.  The list contains a itemRenderer that pulls in a custom component for displaying the information I want from Twitter.  Here is the code for the component called Tweet:


      <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" verticalScrollPolicy="off">


          <mx:Image width="50" height="50" source="{data.link[1].href}" />
           <mx:Text width="100%"  id="twitterText" text="{data.title} {'\n'} {data.author.name} {data.published}" /> 


      pretty simple.  The problem is, the text componnent does not resize its height to the amount of text, so my text is cut off.  If i set a static height, I have too much white space on short tweets.  I have tried changing the height with AS3 but can't seem to get it to work.  Any ideas?


      Here is the the list component I am using:

        <mx:Canvas width="100%" height="100%" x="0" y="100" backgroundColor="#FF0000" borderStyle="none">                       
                  <mx:List dataProvider="{ac}" itemRenderer="Tweet" top="58" left="0" right="0" bottom="40" id="theList"></mx:List>


      Oh and if it helps,  I am using the same method Lee Brimelow teaches in his 3 beginner Flex tutorials on his site gotoandlearn.com

        • 1. Re: Dynamically resize a text component
          Woodifer01 Level 1

          I finally figured out the problem.  The problem was not with the text component but rather the list component.  Here is my list component now:


          <mx:List dataProvider="{ac}" itemRenderer="Tweet" id="tweetList" top="0" left="0" right="0" bottom="145" themeColor="#A5A5A5" variableRowHeight="true"></mx:List>


          I ran across the property variableRowHeight.  It defaults to false.  When set to true, each item in the list can be a different size.  The textarea was resizing correctly.