Reputation: 3859
I have a tile layout containing a list of TextInputs and text fields , i have created these fields in a custom component using the following code;
var newTextInputs:Array = [];
var newTextLabels = [];
var space:Number = 30;
var count:Number = 0;
for (var i:String in columnsData)
{
//create text labels
var label:Text = new Text();
label.name = "label" + count;
label.text = i;
newTextLabels[count] = label;
addChild(newTextLabels[count]);
// create text fields
var field:TextInput = new TextInput();
field.name = "field" + count;
field.width = 100;
field.height = 25;
field.text = columnsData[i];
newTextInputs[count] = field;
addChild(newTextInputs[count]);
count++;
}
users are allowed edit the values in each TextInput field, now i need to retrieve the newly udpated values however how can i access these fields? Because the identifiers are created dynamically i cant simply go componentName.InputFieldName, any ideas?
Upvotes: 0
Views: 2612
Reputation: 5478
I think what you're looking for is getChildByName
later edit: tested with Flash and TextField and it works:
trace(TextField(getChildByName('textfield')).text);
Upvotes: 2
Reputation: 37655
You can add an event handler for the TileList CHANGE event; when it fires, I think the event.target property will have the specific TextInput field. Alternatively you can look at the TileList.SelectedItem property.
You may also be able to have a DataProvider bound to the TileList instead of your code as shown, which will handle this automatically for you. Try just assigning your NewTextLabels array as the dataProvider.
Upvotes: 1