Flex 3:文本输入的动态创建和绑定 [英] Flex 3: Dynamic creation and binding of textinput

查看:23
本文介绍了Flex 3:文本输入的动态创建和绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人有关于如何创建动态数量的 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,其中 label.text 绑定到 textinput 中的数据.这应该是您代码的一个很好的起点.

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:文本输入的动态创建和绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆