How to get html text in a Flex Alert panel.

Tagged:  

A client asked me to do something seemingly simple.
"I want the Alert to have just this one sentence bolded."

Well, it's not exactly simple, so here's how you do it:

  var str:String = "There was a problem with your form. ";
  str += " <b>Would you like to continue without saving?</b>";
  var alert:Alert = Alert.show(str, "Problems in data entry", Alert.YES | Alert.NO, 
                                                         Application.application as Sprite);
  use namespace mx.core.mx_internal;
  IUITextField(alert.alertForm.textField).htmlText = str;

It's kind of an ugly hack, you are basically re-setting the htmlText on the textField only accessible through the mx_internal namespace. This may not work if the html text is a very different size from the regular text. There are probably better ways to do this, but this was the first solution I could come up with.

You saved me a lot of time! Thanks