Skip navigation
Currently Being Moderated

HTML Tags Don't Work When Text Resized

Jul 23, 2012 9:33 AM

Tags: #as3 #html #as3.0 #dynamic_text #textfield #html_tag

I have a text field that gets populated dynamically.  If the populated text doesn't fit in the text field, the text gets resized.  HTML tags work correctly in the dynamically populated text, but only if the text doesn't get resized.  HTML tags are completely ignored in resized text.  Any ideas?


Code to format the text field:

import flash.text.TextFormat;

import flash.text.Font;


function setDesc(str:String):void{

  var fmtD:TextFormat;

  var cfmtD:TextFormat = this.desc_txt.getTextFormat()==null ? this.desc_text.defaultTextFormat : this.desc_txt.getTextFormat();

  var sizeD:int = 22;

  desc_txt.htmlText = str;

  while (sizeD>10 && sizeD<23 && desc_txt.textHeight>255){


     fmtD = new TextFormat(descFont.fontName,sizeD,0x000000,false,false,false);

     desc_txt.htmlText  str;





Code to populate the text field:

function openDialog(e:MouseEvent){



        case "btn_structure":

            dialog_window.setTitle("Title #1 Goes Here");

            dialog_window.setDesc("Topic description goes here.");


        case "btn_services":

            dialog_window.setTitle("Title #2 Goes Here");

            dialog_window.setDesc("<b>Topic</b> description goes <i>here</i>.");




  • Currently Being Moderated
    Jul 23, 2012 9:34 AM   in reply to odedreturns1

    The message you sent requires that you verify that you

    are a real live human being and not a spam source.



    To complete this verification, simply reply to this message and leave

    the subject line intact or click the link below:



    The headers of the message sent from your address are shown below:


    From Mon Jul 23 11:33:54 2012

    Received: from (

         by with esmtps (TLSv1:AES256-SHA:256)

         (Exim 4.77)

         (envelope-from <>)

         id 1StLZy-0008WD-EN

         for; Mon, 23 Jul 2012 11:33:54 -0500

    Received: from (unknown

         by (Postfix) with ESMTP id 0921E600049

         for <>; Mon, 23 Jul 2012 10:33:53 -0600 (MDT)

    Date: Mon, 23 Jul 2012 10:33:52 -0600

    Mark as:
  • Currently Being Moderated
    Jul 23, 2012 11:46 AM   in reply to odedreturns1

    I wrote this and it works, maybe this will help:


    var txt:TextField = new TextField();


    txt.width = stage.stageWidth;

    txt.height = stage.stageHeight;

    txt.multiline = true;


    var format:TextFormat = new TextFormat();

    format.size = 20;

    txt.defaultTextFormat = format;




    var str:String = "here <br> <b> are </b> <br> some <br> html <br> <i> tags </i>";


    txt.htmlText = str;


    //stop the script here and the font size is 20.


    function resizeText(o:TextField, size:int):void


        var newFormat:TextFormat = new TextFormat();

        newFormat.size = size;




    resizeText(txt, 12);


    //stop the script here and the font size is 12.

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points