Flash CS4 <b> tag using htmlText
Wow, this is really weird.
I have the following setup:
Two text boxes on the scene with Arial normal and Arial in bold, both embedded. Then I have another text box that I set like this:
tb.htmlText = "Test <b>Test</b>";
For some reason, bold text is not displayed as bold, but as normal weight. I tried embedding fonts in the library using the [Embed] meta tag, and even resorted to using CSS to force fontFamily to be created. Oddly enough, I can use Font.enumurateFonts and see that both fonts are embedded, but the text field refused to use the bold version inside the <b>.
I was told that this is a problem with Flash CS4 on Mac and that it will work on PC. However, I refuse to believe that this is so. Surely Adobe would fix this already?
Any help would be appreciated.
You should have a bold font in the font list (in the same or another text box):
var fonts:Array = ( Font.enumerateFonts() );
for each( var fo in fonts ){
trace ( fo.fontName ,":", fo.fontStyle )
}
I think that if the font were returned as bold, it probably should work without problems. Here's the solution:
var css:StyleSheet = new StyleSheet()
css.setStyle( "bold" , { fontFamily:"Myriad Pro Bold" } ) // you can catch the fontname in the list that was printed by the code above...
txtfield.styleSheet = css;
txtfield.htmlText = "regular or<bold>bold font</bold>."