Sunday, 9 January 2011

AS3 Bold and Italic text in dynamic text fields

Dynamic text fields in Flash CS4 don’t show Bold or Italic text for some bizarre reason. I found this out when I tried to set the character style of a dynamic text field to Italics. When I exported the movie the Italic text did not appear. I try the Bold character style and that also did not appear.

I figured out you can get around this problem by using the TextFormat class.
Here is the code I used for the Italic text.

output_txt.text='hello ilike2flash';
var ItalicText:TextFormat = new TextFormat();

The code for the bold text is similar.
output_txt.text='hello ilike2flash';
var BoldText:TextFormat = new TextFormat();   

Another solution is to use the Italic tags in the htmlText.
output_txt.htmlText = "<I>Hello</I>"
If the Bold or Italic text still does not appear in the dynamic text field. You can try embedding the fonts.


gooooooogle 25 April 2011 at 21:03  

Good one, both solutions worked.

  COPYRIGHT © 2014 · ILIKE2FLASH · Theme by Ourblogtemplates

Back to TOP