import mx.containers.ControlBar;
import mx.controls.*;
import flash.events.MouseEvent;
private var myCB:ControlBar=new ControlBar();
private var myLabel:Label=new Label();
private var myNS:NumericStepper=new NumericStepper();
private var mySpacer:Spacer=new Spacer();
private var myButton:Button=new Button();
private function addCBHandler():void {
myLabel.text="Quantity";
mySpacer.percentWidth=100;
myButton.label="New Button";
myButton.addEventListener('click', addToCart);
myCB.percentWidth=100;
myCB.addChild(myLabel);
myCB.addChild(myNS);
myCB.addChild(mySpacer);
myCB.addChild(myButton);
myPanel.addChildAt(myCB, myPanel.numChildren);
myPanel.createComponentsFromDescriptors();
}
private function addToCart(event:MouseEvent):void {
Alert.show("Button clicked.");
}