Just started learning Flex. But I am struck up with basic code. I am trying to check how to add components (say button) to the Application container by Action Script. But I am not able to see the buttons in the output. Below is my code,
<?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>
What is the mistake I am doing here?
Thanks