如何在 Flex 3 中使用 htmlText 作为单选按钮标签 [英] How to use htmlText as Radio button label in Flex 3

查看:25
本文介绍了如何在 Flex 3 中使用 htmlText 作为单选按钮标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 Flex 3 中为单选按钮显示几个粗体字.如下所示:

I need to show few words in bold for radio buttons in Flex 3. something like the following:

选项 1:你好 世界.

选项 2:你好世界.

我看到单选按钮的标签没有 htmlText 属性.有人对完成此要求有什么建议吗?

I see that there is no htmlText property for label of Radio Button. Anyone has any suggestions in accomplishing this requirement?

谢谢

安吉

推荐答案

@Timofei Davydik

@Timofei Davydik

您可以通过扩展 RadioButton 并覆盖 updateDisplayList 函数在 RadioButton 标签中包含 HTML 文本.您需要在此函数中将 textField 的 htmlText 属性更改为标签的值.

You can include HTML Text inside RadioButton labels by extending RadioButton and overriding the updateDisplayList function. You need to change htmlText propert of textField to label's value inside this function.

这里是 HTMLRadioButton 组件

Here is the HTMLRadioButton Component

package components
{

import mx.controls.RadioButton;

public class HTMLRadioButton extends RadioButton
{
  public function HTMLRadioButton()
  {
    super();
  }

   override protected function updateDisplayList(unscaledWidth:Number,
                                              unscaledHeight:Number):void
   {
        super.updateDisplayList(unscaledWidth, unscaledHeight);
        textField.htmlText = label;

   }
}
}

更新:

如果您需要 RadioButton 标签中的多行 HTML,那么您需要扩展此 组件同上.

If you need multiline HTML in RadioButton label, then you need to extend this component in the same way as above.

这篇关于如何在 Flex 3 中使用 htmlText 作为单选按钮标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆