How to use htmlText as Radio button label in Flex 3

折月煮酒 提交于 2019-12-04 06:08:27

问题


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

option 1: Hello world.

option 2: Hello world.

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

Thanks

Anji


回答1:


@Timofei Davydik

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.

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;

   }
}
}

Update:

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



来源:https://stackoverflow.com/questions/5618588/how-to-use-htmltext-as-radio-button-label-in-flex-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!