Search This Blog

Thursday, June 16, 2011

Flex add Buttons to an array; Flex add spark.components.TextInput to an mx.collections.ArrayCollection;

Whether you add buttons or textInput does not really matter. I had a couple of text inputs and wanted to change their properties all at once so I added them to an array.

TextInputs:

<s:TextInput x="10" y="6" width="287" fontWeight="bold" id="TestNameInput" />
<s:TextInput x="10" y="42" width="287" fontWeight="bold" id="IPInput" />
<s:TextInput x="10" y="74" width="287" fontWeight="bold" id="HostInput" />
<s:TextInput x="9" y="111" width="287" fontWeight="bold" id="CustomerInput" />
<s:TextInput x="10" y="150" width="287" fontWeight="bold" id="AppInput" />
<s:TextInput x="10" y="186" width="287" fontWeight="bold" id="MemoInput" />

Declare an array collection:

public var inputFieldsArray:ArrayCollection = new ArrayCollection(null);

Add text inputs to an array in the creation event:

protected function group1_creationCompleteHandler(event:FlexEvent):void
{
     //adding input fields to the array
     inputFieldsArray.addItem(TestNameInput);
     inputFieldsArray.addItem(IPInput);
     inputFieldsArray.addItem(HostInput);
     inputFieldsArray.addItem(CustomerInput);
     inputFieldsArray.addItem(AppInput);
     inputFieldsArray.addItem(MemoInput);
}

No comments:

Post a Comment

If you like this post, please leave a comment :)