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){

     sizeD--;

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

     desc_txt.htmlText  str;

     desc_txt.setTextFormat(fmtD);

  }

}

 

Code to populate the text field:

function openDialog(e:MouseEvent){

  dialog_window.doOpen();

     switch(e.currentTarget.name){

        case "btn_structure":

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

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

        break;

        case "btn_services":

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

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

        break;

     }

}

 
Replies
  • 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:

     

    http://www.solutionvix.com/cgi-sys/bxd.cgi?a=jeferson@solutionvix.com& id=b9rQp4Knw4ilGW7h1cmwr-1343061234//www.solutionvix.com/cgi-sys/bxd.cgi?a=jeferson@solutionvix.com&id=b9rQp4Knw4ilGW7h1cmwr-1343061234

     

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

     

    From forums@adobe.com Mon Jul 23 11:33:54 2012

    Received: from mail.sgaur.hosted.jivesoftware.com (209.46.39.252:6927 helo=mx-out4.sgvm2hosted.jiveland.com)

         by lagonda.websitewelcome.com with esmtps (TLSv1:AES256-SHA:256)

         (Exim 4.77)

         (envelope-from <forums@adobe.com>)

         id 1StLZy-0008WD-EN

         for jeferson@solutionvix.com; Mon, 23 Jul 2012 11:33:54 -0500

    Received: from adobe-vm-wa05.sgvm2hosted.jiveland.com (unknown 10.122.0.4)

         by mx-out4.sgvm2hosted.jiveland.com (Postfix) with ESMTP id 0921E600049

         for <jeferson@solutionvix.com>; 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;

     

    addChild(txt);

     

    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;

        o.setTextFormat(newFormat);

    }

     

    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