<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" viewSourceURL="src/GettingStartedActionScript/index.html" creationComplete="creationCompleteHandler()" width="300" height="80" > <mx:Button id="hello" label="jasper" width="20" height="20" x="0" y="0"> </mx:Button> <mx:Script> <!--[CDATA[ //创建按钮 import mx.controls.Button; import mx.events.FlexEvent; private var myButton:Button; private function creationCompleteHandler(): void { myButton = new Button; myButton.label = "I'm a button!"; myButton.addEventListener (FlexEvent.CREATION_COMPLETE,buttonCreationCompleteHandler); addChild (myButton); } private function buttonCreationCompleteHandler( evt:FlexEvent ): void { myButton.x = parent.width/2 - myButton.width/2; myButton.y = parent.height/2 - myButton.height/2; } ]]--> </mx:Script> </mx:Application>