Reorder controls
<?xml version="1.0"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script> import mx.controls.CheckBox; import mx.controls.Alert; private var myCheckBox:CheckBox; private var checkBoxDisplayed:Boolean = false; public function addControlButton():void { if(checkBoxDisplayed == false){ if (!myCheckBox) { myCheckBox = new CheckBox(); } myCheckBox.label = "New CheckBox"; myVBox.addChildAt(myCheckBox, 0); checkBoxDisplayed=true; } } public function reorder():void { if(checkBoxDisplayed==true){ if (myVBox.getChildIndex(myCheckBox) < myVBox.numChildren-1) { myVBox.setChildIndex(myCheckBox, myVBox.getChildIndex(myCheckBox) + 1); } } } </mx:Script> <mx:VBox id="myVBox"> <mx:Button label="Add CheckBox" click="addControlButton();" /> <mx:Button label="Reorder children" click="reorder();" /> </mx:VBox> </mx:Application>