看了下flex的Alert的源码,发现alert出来的按钮、内容文本框其实都在一个AlertForm类实例中,这个实例在Alert类成员中的定义是:
/**
* @private
* The internal AlertForm object that contains the text, icon, and buttons
* of the Alert control.
*/
mx_internal var alertForm:AlertForm;
而其内容文本框在AlertForm中的定义是:
/**
* The UITextField that displays the text of the Alert control.
*/
mx_internal var textField:IUITextField;
ok,相信大家都知道该怎么做了,也就是在mx_internal命名空间下,把这个textfield提取出来,设置其htmltext即可,当然,你也可以进行其他的操作。
源码如下:
var alert:Alert = Alert.show("", "提示");
var tf:IUITextField = alert.mx_internal::alertForm.mx_internal::textField;
tf.autoSize = TextFieldAutoSize.CENTER;
tf.htmlText = "<a href='http://www.asarea.cn' target='_blank'><b><font color='#ffffff' size='13'>欢迎访问ASAREA</font></b></a>";
本文介绍了如何通过提取 Flex 的 Alert 控件内部的文本字段来实现自定义显示内容的方法。通过在 mx_internal 命名空间下获取 textField 对象并设置其属性,可以实现对弹窗文本的 HTML 格式化。
196

被折叠的 条评论
为什么被折叠?



