如何使用在Flash AS3项目Flex的绑定绑定、如何使用、项目、Flash

2023-09-08 15:32:45 作者:触动人心

我在使用Flex框架一个Flash应用程序 - 我想用数据的显示对象textField的从我的数据模型绑定。 如何做到这一点,而不挠结合括号{}

I have a flash app using the flex framework - I would like to bind a display object textField with data from my dataModel. How do I do this without the flex binding brackets "{ }"

在此先感谢大家。

推荐答案

要做到这一点最简单的方法是使用 BindingUtils 类。例如,假设你有一个对象财产吧,你要绑定到你的文本区域的文本财产;所有你需要做的就是在您的ActionScript如下:

The easiest way to do this is to use the BindingUtils class. For example, say you have an object foo with property bar that you want to bind to your text area's text property; all you need to do is the following in your ActionScript:

BindingUtils.bindProperty( myTextArea, "text", foo, "bar" );

这会告诉Flex的观看的任何更改属性,并在发生变化,复制该值 myTextArea.text

This will tell Flex to watch foo for any changes to the property bar, and when changes occur, copy the value to myTextArea.text.

完整文档,可以发现这里