【发布时间】:2010-12-26 13:50:42
【问题描述】:
我在 Visual Studio 中使用 Flex SDK 并尝试向舞台动态添加按钮。这是我正在做的一个简单示例。
public class Test extends Sprite
{
public function Test()
{
init();
}
private function init():void
{
var btnBrowse:Button = new Button();
btnBrowse.label = "Browse";
btnBrowse.x = 0;
btnBrowse.y = 0;
btnBrowse.width=100;
btnBrowse.height=100;
addChild(btnBrowse);
}
}
似乎什么都没有显示,屏幕仍然是空的。我正在为按钮导入 mx.controls.*。由于我不只使用 as3 的 mxml,这会产生问题吗?
【问题讨论】:
-
我假设您也在以某种方式创建 Test 实例并将其添加到显示列表中? mxml 与 as3 不应该成为问题 - 作为编译过程的一部分,所有 mxml 都会在后台转换为 actionscript,因此您在 mxml 中可以做的任何事情都不能在 actionscript 中做。
标签: visual-studio apache-flex actionscript-3