【发布时间】:2012-09-03 15:21:38
【问题描述】:
在 flex 3 中,如何将复选框标签的一部分设为粗体? 说复选框标签是“记住数据网格上的值”。需要将文本“datagrid”单独加粗。任何人都可以请帮忙。 提前致谢。
【问题讨论】:
标签: actionscript-3 apache-flex flex3
在 flex 3 中,如何将复选框标签的一部分设为粗体? 说复选框标签是“记住数据网格上的值”。需要将文本“datagrid”单独加粗。任何人都可以请帮忙。 提前致谢。
【问题讨论】:
标签: actionscript-3 apache-flex flex3
这不是完美的解决方案,但可以帮助您入门。如果你扩展 CheckBox 类,你可以重写 updateDisplayList() 方法,并使用它的 htmlText 属性设置复选框的标签。
然后使用这个自定义复选框并传入带有 HTML 的标签。
这个解决方案的问题:
measure() Flex 生命周期方法)htmlText 属性将其撤消HTMLTextCheckBox.as:
package
{
import mx.controls.CheckBox;
public class HtmlTextCheckBox extends CheckBox
{
public function HtmlTextCheckBox()
{
super();
}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
textField.htmlText = label;
}
}
}
使用 MXML:
<local:HtmlTextCheckBox label="this is the <b>bold part</b>"/>
或者在 AS3 中:
var cb:HtmlTextCheckBox = new HtmlTextCheckBox();
cb.text = "this is the <b>bold part</b>";
【讨论】: