如何在 Flash AS3 项目中使用 Flex 的绑定 [英] How do I use Flex's Binding in a Flash AS3 project

查看:27
本文介绍了如何在 Flash AS3 项目中使用 Flex 的绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 flex 框架的 Flash 应用程序 - 我想将一个显示对象 textField 与我的 dataModel 中的数据绑定.如果没有 flex 绑定括号{}"

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 类.例如,假设您有一个对象 foo,其属性为 bar,您希望将其绑定到文本区域的 text 属性;您只需在 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 监视 foo 是否对属性 bar 进行任何更改,并在发生更改时将值复制到 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.

可以在此处找到完整的文档.

这篇关于如何在 Flash AS3 项目中使用 Flex 的绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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