刚开始学习Flex。但我对基本代码感到震惊。我正在尝试检查如何通过动作脚本将组件(比如按钮)添加到应用程序容器。但我看不到输出中的按钮。下面是我的代码,
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
creationComplete="init()">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import spark.components.Button;
import spark.layouts.BasicLayout;
private function init():void{
var bl:BasicLayout = new BasicLayout();
var app:Application = new Application();
var button1:Button = new Button();
var button2:Button = new Button();
button1.label ="Button one";
button1.x = 100;
button2.label = "Two";
button2.x = 30;
layout = bl;
addChild(button1);
addChild(button2);
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
我在这里做错了什么?
谢谢