Skip to main content
Participant
January 6, 2011
Question

If <b> is first in a string, corrupts the TLFTextField

  • January 6, 2011
  • 1 reply
  • 398 views

Condition:

Create a string with the <b> tag appearing at the beginning, eg.

str = "<b>Bold</b> is the first thing in this string";

Create a TLFTextField on the stage (manually from within flash) and then assign the string to its htmlText property, eg.

myTLFTextField.htmlText = str;

Result:

Everything looks fine - but now try and assign a different string to the same TLFTextField.  The entire text is fixed to being bold, no matter what html tags are present or not.

The same thing happens for the <i> tag as well.

The only work around I have is to always insert a space at the start of the string.  If any <b> or <i> tag appears at the start of the string, that text field is corrupt for the entire session and can't be fixed.

This topic has been closed for replies.

1 reply

Participating Frequently
January 7, 2011

Howdy,

This is a known limitation of our implementation of TLF that pulls the format for text for set text from the first character in a text flow, That is why you see the same for italic and putting a space in works. The only way to be sure you will get what you want is to set the defaultTextFormat to your desired attributes and use ReplaceText instead of setting text, or setTextFormat on all of the text after you do a set text.

Hope this helps,


Craig Simmons

Flash Authoring

DomariusAuthor
Participant
January 9, 2011

Thanks for that, makes a bit more sense, still a little strange - for example, I am using .htmlText, hence the use of <b> tag.  Your solution isn't compatible with html tags, so is there another graceful way around this?