A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: getTextExtent and HTML text

  1. #1
    Junior Member
    Join Date
    Aug 2001
    Posts
    15

    getTextExtent and HTML text

    I just read that using getTextExtent to get the width and height of a dynamic text field will not take into account the html text.

    Is there any work arounds for this?

    I want to use HTML text but my layout will be screwed up and some text fields will be too short if there are BR tags.

  2. #2
    Banned by GMF
    FKs Banning Machine
    jerez_z's Avatar
    Join Date
    Jun 2001
    Location
    Calgary
    Posts
    235
    a thought occured to me when I was reading this.

    go through the text in the text field and take out all "<br>" and replace it with newline (its a new string constant) ie:

    code:

    //ttext is the text your searching though (take the space out of the < br> below
    tarray = ttext.split("< br>");
    ttext = "";
    for (var i = 0;i<=tarray.length-1;i++) {
    if (ttext != "") {
    ttext = ttext+newline+tarray[i];
    } else {
    ttext = tarray[i];
    }
    }

    Last edited by jerez_z; 03-12-2004 at 01:12 AM.

  3. #3
    Junior Member
    Join Date
    Aug 2001
    Posts
    15
    That will work for breaks, but I also need it for <a href>

    I hacked it by creating a dummy text field which i set the text of, read the textHeight and textWidth, and the create a new text field based on that. with the hieght and width that i read from the dummy.

    i am very dissapointed flash doesn't support getTextExtent for html text.

  4. #4
    Banned by GMF
    FKs Banning Machine
    jerez_z's Avatar
    Join Date
    Jun 2001
    Location
    Calgary
    Posts
    235
    just a note about the above code. it appears it is the indetical funtionality to:

    code:

    ttext = ttext.split("< br>").join(newline);



    I didn't do enough R&D.....

    Thanx to jbum^

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center