Creating and removing children of an Accordion container
<?xml version="1.0"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script> import mx.containers.HBox; private var hBoxes:Array = []; public function addControlButton():void { var newHB:HBox = new HBox(); newHB.label = "my label: " + String(hBoxes.length); hBoxes.push(myAcc.addChild(newHB)); } public function deleteControlButton():void { if (hBoxes.length>= 1) { myAcc.removeChild(hBoxes.pop()); } } </mx:Script> <mx:VBox> <mx:Accordion id="myAcc" height="150" width="150"> <mx:HBox label="Initial HBox" /> </mx:Accordion> <mx:Button label="Add HBox" click="addControlButton();" /> <mx:Button label="Remove HBox" click="deleteControlButton();" /> </mx:VBox> </mx:Application>