Make your own free website on

Fail to show wordWrapping in TextField with EmbedFonts
by Eric Lin

download fla in zip

Any textfield created by dragging during design time or dynamically created by "createTextField", should have "font name" to it. For textfield created on design time, Flash compiled the FontID of the specified font to the swf. Dynamically created textfield has "Times New Roman" font as default. When we make it "embedfont=true;", It will display the text by the font specified above.

If we are going to display different font, we can use htmlText and specify the font in the <font> tag.

It works without problems.

Flash 6 supply functions to change the font. Here we can give each paragraph a font, even in plain text Textfield. There are two functions. One is setTextFormat(tf). This function is applied to paragraphs on textfield with text already loaded. The other is setNewTextFormat(tf). This function applied to text that is going to be loaded in.

EmbedFonts-->setNewTextFormat(tf_with_new_font)-->load text; This seems all right;

EmbedFonts-->load Text-->setTextFormat(tf_with_new_font); This evokes some bugs.

Essentially, setTextFormat without specifying the startIndex and endIndex, should apply that textformat to all paragraphs. However, the wordwrapping is not correct after 2-3 paragraphs. All properties of the textformat are applied except the wordwrapping.

There are several ways to fix this.

1. Use setNewTextFormat before new text loading; OR

2. Set embedfonts=false; before text loading. Set embedfont=true; after textloaded. This is slightly awkuard to set embedfont=false; every time; OR

3. Apply textformat for each paragraph. I tried that:


This works. However, I am not sure of the reasons what these codes did.