如何使用的htmlText作为单选按钮标签在Flex 3的如何使用、单选、按钮、标签

2023-09-09 21:41:31 作者:冷眼看世界ヽ

我需要显示几句大胆单选按钮在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

您可以通过扩展单选按钮并覆盖updateDisplayList函数中包括内部单选按钮标签的HTML文本。你需要改变了TextField的htmlText PROPERT这个函数内标签的价值。

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;

   }
}
}

更新:

如果您需要多行HTML的单选按钮的标签,那么你需要扩展这个组件的在与上述相同的方式

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