Insert bold into the AS3 Flash dynamic field

I already searched Google and read a lot of different topics related to this problem, but still I can not solve my problem. I have this dynamic text box in a movie clip and I have uppercase, lowercase and numbers. I exported this movieclip, then used it in my class and loaded data from xml.

However, after I embedded the bold font, it stopped displaying data from xml, if I use regular, this is normal. Then I created a font symbol and added bold to the library, it still gives me nothing.

Does anyone know how to solve this problem?

thanks.

+6
flash fonts actionscript-3 embed
source share
4 answers

The easiest way to fix this problem is to create a set of off-screen text fields. Each field will handle the attachment for one combination of fonts and weights that you need. For example, if you need regular, bold, italics, as well as bold and italics for one font, you will have 4 text fields - each with inclusion turned on and the required characters.

Then you can simply enable the font attachment for any other text field, and it will be able to use all four styles (of this font).

+2
source share

I tried to change any font instance of the embedded version without success. However, I was able to use the solution offered on the Adobe forum here:

http://forums.adobe.com/thread/716363

Instead of using myTextFieldInstance.text use myTextFieldInstance.htmlText and specify "<b>" + yourStringValue + "</b>" at the time of assignment. While kludgey to max, it was an easy solution to the problem.

+2
source share

I assume that you are using one of the latest versions of the Flash IDE.

Sounds like a conflict to me. If you have another text box in this movie with the same font and weight, but not for the embedded font, there will be a quiet (and annoying) conflict. The solution is for all text fields, including static and input, to be set with a font in the font list with an asterisk, i.e. Arial *.

If this does not help you, I suggest you embed the font using the [embed] MXML tag (cs4 only). Lee Brimelou has an excellent video tutorial on this technique where you can watch it on gotoAndLearn .

I had problems with embedded fonts and the embed tag fixed this for me. Check out my post and see if that helps.

+1
source share

There is a problem with using the Bold font.

The font is not set to BOLD with the following code if you dynamically update the text later somewhere in the code.

 var myTextFormat:TextFormat = new TextFormat(); myTextFormat.font = "Arial"; myTextFormat.bold = true; myTextField.setTextFormat(myTextFormat); // myTextField.text = "some dynamic text"; 

Instead, you need to apply a text format every time you update the text.

 var myTextFormat:TextFormat = new TextFormat(); myTextFormat.font = "Arial"; myTextFormat.bold = true; // myTextField.text = "some dynamic text"; myTextField.setTextFormat(myTextFormat); 

But I usually set it as the default font, as shown below,

 var myTextFormat:TextFormat = new TextFormat(); myTextFormat.font = "Arial"; myTextFormat.bold = true; myTextField.defaultTextFormat = myTextFormat; // myTextField.text = "some dynamic text"; 

Not an ideal way for a reliable project, but it works.

0
source share

All Articles