如何在flex 3中创建动态标签和按钮?
答案 0 :(得分:1)
public function yourFunction():void
{
var tmpLbl:Label = new Label();
tmpLbl.x = 10;
tmpLbl.y = 5;
tmpLbl.text = "Label Text";
yourObj.addChild(tmpLbl); // where yourObj is the object you want to add the label to
}
除了按钮文本之外,按钮的相同处理将使用btn.Label设置
要添加onclick事件,请使用
btn.addEventListener(MouseEvent.CLICK, ...