Use a Button control inside the HBox
<?xml version="1.0"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script> import mx.controls.Button; public var button2:Button; public function createObject():void { button2 = new Button(); button2.label = "Click Me"; hb1.addChild(button2); } </mx:Script> <mx:HBox id="hb1"> <mx:Button label="Create Object" click="createObject()" /> </mx:HBox> </mx:Application>