【发布时间】:2011-09-21 04:47:07
【问题描述】:
我正在尝试在 flex4 中创建一个可编辑的标签。
为此,我扩展了文本字段类,因此它包含一个标签控制元素。但是,一旦文本字段变得不可见,我就无法使标签可见。
代码如下所示:
package unimap.components
{
import spark.components.Label;
import spark.components.TextInput;
public class SmartTextInput extends TextInput
{
private var _label:Label;
public function SmartTextInput()
{
super();
}
public override function set editable(value:Boolean):void
{
super.editable = value;
if (value == false)
{
_label = new Label();
_label.x = this.x;
_label.y = this.y;
_label.width = this.width;
_label.height = this.height;
_label.text = "Home";
addChild( _label ); // This lines fail the code with error
// Error: addChild() is not available in this class. Instead, use addElement() or modify //the skin, if you have one.
}
super.visible = false;
trace("Editable")
}
}
}
但是如果我将 addChild 更改为 addElement 我会看到以下错误: 1180: 调用可能未定义的方法 addElement。
有人可以建议我做错了什么吗?
【问题讨论】:
标签: apache-flex flex4