• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

HTML Tags Don't Work When Text Resized

Guest
Jul 23, 2012 Jul 23, 2012

Copy link to clipboard

Copied

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;

     }

}

TOPICS
ActionScript

Views

642

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 23, 2012 Jul 23, 2012

Copy link to clipboard

Copied

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

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 (: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 )

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 23, 2012 Jul 23, 2012

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 23, 2012 Jul 23, 2012

Copy link to clipboard

Copied

LATEST

Solution found on another forum:

var desc_txt:TextField = new TextField(); addChild(desc_txt);

function setDesc(str:String):void{

  var sizeD:uint=22;

  var fmtD:TextFormat;

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

  desc_txt.width=455.50;

  desc_txt.height=263;

  desc_txt.x=17.50;

  desc_txt.y=61.20;

  desc_txt.wordWrap=true;

  desc_txt.defaultTextFormat=fmtD;

  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.defaultTextFormat=fmtD;

     desc_txt.htmlText=str:

  }

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines