<?xml version="1.0" encoding="utf-8"?>
<mx: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" preloaderChromeColor="#C6EDC7" creationComplete="sayHello()">
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<mx:Text x="20" y="20" id="mytext"/>
<fx:Script>
<![CDATA[
public function sayHello():void{
mytext.text="MXML Say:http://deepfuture.iteye.com";
var codetxt:Text=new Text;
codetxt.text="code say:hello world!";
codetxt.x=80;
codetxt.y=100;
this.addChild(codetxt);//加入显示列表
}
]]>
</fx:Script>
</mx:Application>
或者
<?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" preloaderChromeColor="#C6EDC7" creationComplete="sayHello()">
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<mx:Text x="20" y="20" id="mytext"/>
<fx:Script>
<![CDATA[
public function sayHello():void{
mytext.text="MXML Say:http://deepfuture.iteye.com";
var codetxt:Text=new Text;
codetxt.text="code say:hello world!";
codetxt.x=80;
codetxt.y=100;
addElement(codetxt);
}
]]>
</fx:Script>
</s:Application>