Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8278033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:52:18+00:00 2026-06-08T08:52:18+00:00

I have a text field that gets populated dynamically. If the populated text doesn’t

  • 0

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 completed ignored in resized text. Any ideas?

Code for 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("Business Structure:");
            dialog_window.setDesc("This topic discusses the <b>basic</b> structure of the business area.");
         break;
         case "btn_services":
            dialog_window.setTitle("Services Provided:");
            dialog_window.setDesc("This topic provides <i>information</i> about the services offered by the Client Billing Services unit.");
         break;
    }    
} 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:52:19+00:00Added an answer on June 8, 2026 at 8:52 am

    Try changing the last two lines inside the while loop to:

    desc_txt.defaultTextFormat = fmtD;
    desc_txt.htmlText = str;
    

    You can read more about working with html tags and the as3 TextFormat class here

    EDIT:

    I just set up this simple example using bits of your code and both the text formatting (font type and size) and html tags (bold and italics) are working flawlessly:

    import flash.text.TextField;
    import flash.text.TextFormat;
    
    var sizeD:uint = 22;
    var desc_txt:TextField = new TextField();
    addChild(desc_txt);
    
    var str:String = "This topic <i>discusses</i> the <b>basic</b> structure of the business area. This topic <i>discusses</i> the <b>basic</b> structure of the business area.This topic <i>discusses</i> the <b>basic</b> structure of the business area. This topic <i>discusses</i> the <b>basic</b> structure of the business area.";
    
    var fmtD:TextFormat;
    fmtD = new TextFormat("Verdana",sizeD,0x000000,false, false,false);
    
    desc_txt.width=450;
    desc_txt.height=150;
    desc_txt.wordWrap=true;
    
    desc_txt.defaultTextFormat = fmtD;
    desc_txt.htmlText = str;
    
    var maxHeight = 150;
    
    trace(sizeD+" - "+ desc_txt.textHeight);
    while(sizeD>10 && sizeD<23 && desc_txt.textHeight>maxHeight)
    {
      trace("--> inside while loop");
      sizeD--;
      fmtD = new TextFormat("Verdana",sizeD,0x000000,false, false,false);
      desc_txt.defaultTextFormat = fmtD;
      desc_txt.htmlText = str;
    
    }
    trace(sizeD+" - "+desc_txt.textHeight);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an AWT text field that gets enabled and disabled based on the
I have a text field that is near the bottom of the screen. When
I have a text field that is a date, although sometimes it also has
I would like to have a text field that a user can enter a
I'm have a TextViewCell with a text field that that I'm using in a
I have 1.5 million records, each with a text field body that contains a
I have field that it's not a key (it's text) and I want to
If have an event that fires when a user clicks outside of text field,
I have a loop that enters each non-empty text field into a database: foreach
I have a long text field and what I want to do is that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.