3 Replies Latest reply on Mar 30, 2010 2:48 PM by Flex harUI

    How do I get the textWidth of a Text component?

    adamgeework

       import mx.core.mx_internal;
      use namespace mx_internal;
      
                  var txtIt:Text = new Text();
      
      
      
                      txtIt.text = full_array[t][0];
                      txtIt.width = 700;
                      txtIt.buttonMode = true;
                      txtIt.mouseChildren = false;
                      txtIt.selectable = false;
                      txtIt.y = t * 30;
      
                      var txtfld:TextField = txtIt.getTextField() as TextField;
                      trace(txtfld.textWidth);
      
      
                      myCanvas.addChild(txtIt);
      
      

       

      This should be giving me the textWidth of the Text component? It just gives me a null error.

       

      How do I get the textWidth of a Text component?