2 Replies Latest reply on Jul 13, 2006 6:00 AM by inlineblue

    Component size

    mablack
      Is there a way to get the height and width of the contents of a component, including the area not currently being drawn on screen?
      I need to get the size of the contents of a TextArea, but I can only find a way to get the size of the visible area (the scrollable rectangle).
      I need this for printing a TextArea that's rendering some HTML content, but it will only print the area that's currently visible on the screen. If I make a new component to handle the printing, I need to set the size of it, or it will have the same problem...

      Thanks,
      Michael
        • 1. Re: Component size
          jpwrunyan Level 1
          I don't think there is a good way to do this... but I can give you a "hacky" solution:

          1) Turn the h/v scrollPolicy off on your TextArea.
          2) put the TextArea inside a Box.

          the box will be displaying the scroll bars now and is the "visible" area.
          the TextArea will match the size of the HTML text and its height/width will always be that of the text.

          <mx:Box>
          <mx:TextArea id="content" horizontalScrollPolicy="off" verticalScrollPolicy="off" htmlText="{source}" />
          </mx:Box>
          <mx:Button click="Alert.show('w: '+content.width)" />

          I am pretty sure something along those lines will help solve your problem though it does involve an extra container.
          • 2. Re: Component size
            inlineblue Level 1
            If you're just talking about TextArea, try usng the textHeight and textWidth properties.