Flex 3的:动态创建和TextInput结合 [英] Flex 3: Dynamic creation and binding of textinput
问题描述
有没有人对如何创建的TextInput
箱一个动态数字,让每个被键入这些框中的文字被绑定到标签的任何例子吗?例如,假设我有一个XML文件,该文件规定,我想3 的TextInput
框。那么Flex的要以此数据,创建的TextInput
箱,每个创建绑定变量的TextInput
,并创建一个标签来显示什么是被键入的每一个的TextInput
。我在遇到解决此方案最大的问题是如何将数据绑定的变量数量。任何想法?
Does anyone have any examples on how to create a dynamic number of TextInput
boxes and have each of the text being typed in these boxes be bound to a label? For example, say I have an XML file that specifies that I want 3 TextInput
boxes. Flex should then take this data, create the TextInput
boxes, create bindable variables for each TextInput
and create a label to display what is being typed for each TextInput
. The biggest issue I'm having with solving this scenario is how to bind a variable amount of data. Any ideas?
推荐答案
这个函数创建一个对的TextInput /标签,其中label.text被绑定到数据的TextInput的。这应该是一个很好的起点为您的code。
This function creates a pair of textinput/label, where label.text is binded to data in textinput. This should be a good starting point for your code.
private function createTextFieldWithLabel ():void
{
var tf:TextInput = new TextInput();
var label:Label = new Label();
var binding:ChangeWatcher = BindingUtils.bindProperty(label, "text", tf, "text");
var hbox:HBox = new HBox();
hbox.addChild(tf);
hbox.addChild(label);
addChild(hbox);
}
这篇关于Flex 3的:动态创建和TextInput结合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!