2 Replies Latest reply on Jun 23, 2006 3:11 PM by jeddhorvath

    How to parse pixel length of loaded text?

      Hi all,

      For the purposes of a scrolling text field which dynamically loads content from a jsp, I would like the text field to crop itself according to how many lines of content is loaded (if only a small paragraph is to be loaded, th text box should be small, so as to not scroll very far/sensitively, and vise-versa). But I am not sure how to most precisely get Flash to examine the data that gets loaded to the text box and convert it to pixel dimensions. I'm currently using something quite inexact, based on character width and line height estimates (here using Verdana 11px):

      onClipEvent (data) {
      var charWidth = 15; //arbitrary
      var charHeight = 15; //arbitrary
      this.theTextField._height = ((myLoadedTextString.length*charWidth)/this.theField._width)*charHeight;

      This happens to do the trick, but won't work very well with varying sizes of data loaded/different formatting options in the text field/loaded HTML data. Does anyone have a better solution?

      Thanks very much,