1 Reply Latest reply on Jul 15, 2008 5:38 PM by Xopods

    Measuring lines of Text

    Xopods
      Hi. I'm adding text to Text objects for which I've specified a width, but not a height, and need to know the number of lines (or height in pixels) that end up being used. That is, I'm doing something like this:

      var my_text:Text = new Text();
      my_text.width=400;
      my_text.setStyle("fontSize",9); // etc. etc.
      my_text.text = my_string;
      my_text.validateNow();
      my_text.validateSize();
      trace(my_text.height);
      trace(my_text.textHeight);

      --------

      Despite calling validateNow() and whatever else I can think of, it always gives me 0 for height, and 13 pixels (= 1 line) for textHeight, even if the text actually wraps onto several lines.

      What do I need to do?