1 Reply Latest reply on Jan 13, 2010 12:51 PM by Gregory Lafrance

    Text not resizing itself?

    andrewthorp

      I have a VBox, it has one child (<mx:Text />, also tried <mx:Label />).

       

      In creationComplete for the VBox, I set a bunch of styles for the Text (fontFamily, fontStyle, fontSize, fontWeight, color, etc).

       

      After I set all of the styles, I set the htmlText of the Text control (have also tried using .text instead) and for some reason the height is not resizing itself to display the text correctly. It is only showing me the top portion of the text, as if it thinks it is size 12 text, when I am setting it to size 40 text.

       

      I tried calling myText.invalidateSize(); after I set all of the styles (though I admit I have never TRULY understood when/why to use invalidation).

       

      Thanks for any help!

        • 1. Re: Text not resizing itself?
          Gregory Lafrance Level 6

          It works in this code, how does your code differ (in terms of differences significant to the problem):

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
            <mx:Script>
              <![CDATA[
                private function init():void{
                  txt.setStyle("fontFamily", "arial");
                  txt.setStyle("fontStyle", "italic");
                  txt.setStyle("fontSize", 40);
                  txt.setStyle("fontWeight", "bold"); 
                  txt.setStyle("color", 0x0000FF);
                  txt.text = "This is some sample text.";    
                }
              ]]>
            </mx:Script>
            <mx:VBox creationComplete="init();">
              <mx:Text id="txt"/>
            </mx:VBox>
          </mx:Application>
          


          If this post answers your question or helps, please mark it as such.


          Greg Lafrance - Flex 2 and 3 ACE certified

          www.ChikaraDev.com

          Flex / AIR Development, Training, and Support Services