1
我想重写Label组件中的文本设置器,但它的行为很奇怪 有时super.text有效,有时候不行!痕迹显示我的代码没有错误。在Adobe Flex中重写MXML组件中的setter
这里是我的代码:
import spark.components.Label;
public class LabelXX extends Label
{
private var _initialText:String;
private var _assignedText:String;
public function LabelXX()
{
super();
}
override public function set text(value:String):void
{
if (!_initialText)
{
_initialText = value;
super.text = value;
trace("initial text = " + value);
}else
{
_assignedText = value;
super.text = _initialText + " " + _assignedText;
trace("Now: " + _initialText + " " + _assignedText);
}
//this wont have any effect no matter what I do:
//super.text = "test test test";
}
override public function get text():String
{
if (!_assignedText)
{
return "";
}else
{
return _assignedText;
}
}
}
UPDATE:如果我评论它工作正常,吸气仍然没有任何意义!
感谢
“有时super.text有效,有时不是!”你能否详细说明一下?如果我们不知道什么是错的,我们不能帮助你。 – JeffryHouser 2011-12-15 16:51:18