Actionscript 3 动态标签和按钮

Actionscript 3 动态标签和按钮,actionscript-3,apache-flex,flex3,Actionscript 3,Apache Flex,Flex3,如何在Flex3中创建动态标签和按钮 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 }

如何在Flex3中创建动态标签和按钮

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, ...

对此,有很多可能的答案。你能提供一些上下文吗?您在什么情况下尝试创建动态标签?你只是想根据其他变量值更改按钮的标签吗?谢谢Chris。我找到了解决方案。