Flash Builder 4 How to create a add button to add instance of textbox and combobox?
I have tried to work on a simple form with Flash Builder 4, but was stuck in creating the dynamic addition of the instance for a textbox and comb开发者_高级运维obox within a Hbox.
I have created an HBox component with a textbox and a combo box. I then create a button Add new Row, to add a new row of Hbox on the runtime.
May I know how can I create the add to make it able to add new hbox component on clicking of the button, such that when i click the hbox 3 times, I should have 3 rows of the component instance and the button is still at the bottom of these components?
Thanks.
Take a look on the code:
<mx:Script>
<![CDATA[
protected function button1_clickHandler(event:MouseEvent):void{
var textInput:TextInput = newTextInput();
vbox.addChildAt(textInput,0);
}
]]>
</mx:Script>
<mx:VBox id="vbox">
<mx:Button click="button1_clickHandler(event)" label="Click"/>
</mx:VBox>
I'm creating a simple text field, and not a custom component as in your case, however I think you can get the idea. I also recommend isolating your mxml component (hbox+childrens) in a different file, for better clarity.
精彩评论