/*forked from tomohero's flash on 2009-2-25*/ /* The code doesn't actually produce the sWF on the right. That SWF was generated when I originally forked from the original. This code doesn't compile at all. */ package { import mx.controls.Button; import mx.events.FlexEvent; public class whatever { public function whatever() { } private var myButton:Button; private function creationCompleteHandler():void { // Create a Button instance and set its label myButton = new Button(); myButton.label = "I'm a button!"; // Get notified once button component has been created and processed for layout myButton.addEventListener (FlexEvent.CREATION_COMPLETE, buttonCreationCompleteHandler); // Add the Button instance to the DisplayList addChild (myButton); } private function buttonCreationCompleteHandler ( evt:FlexEvent ):void { // Center the button myButton.x = parent.width/2 - myButton.width/2; myButton.y = parent.height/2 - myButton.height/2; } } } Trying to create Flex button via pure AS