弹性+复选框 +数据提供者...很可能是您今天要回答的最简单的问题
也许我昨晚没睡够,但我遇到了一个奇怪的 Flex 3.4 问题。
场景:
我有一个类,它为我的整个应用程序充当数据提供者,名为“DataProvider.as”:
package
{
public class DataProvider
{
[Bindable]
public static var email_enable:Boolean = true;
}
}
在 mxml 表单中,“Settings.mxml”,我有一个复选框控件,它绑定到我的 dataprovider 类的 email_enable 变量:
<mx:CheckBox x="452" y="170" label="{Language.loadLanguageResource('lblEmail')}"
id="chkEmail"
selected="{DataProvider.email_enable}"
change="onChange()"/>
全部是就获取值而言,如果我将数据提供程序中的变量设置为 true 或 false,则复选框会反映此更改;但是,如果我单击该复选框并更改其值,则 dataprovider 变量永远不会反映更改!
我一直用头撞墙,无法解决这个问题。我用谷歌搜索了我的心却无济于事。请救救我。
Maybe I didn't get enough sleep last night but I am encountering a bizarre Flex 3.4 issue.
Scenario:
I have a class that acts a dataprovider to my entire application named "DataProvider.as":
package
{
public class DataProvider
{
[Bindable]
public static var email_enable:Boolean = true;
}
}
In an mxml form, "Settings.mxml" I have a checkbox control which is bound to the email_enable variable of my dataprovider class:
<mx:CheckBox x="452" y="170" label="{Language.loadLanguageResource('lblEmail')}"
id="chkEmail"
selected="{DataProvider.email_enable}"
change="onChange()"/>
All is well as far as getting the value, if I set the variable in my dataprovider to either true or false, the checkbox reflects this change; however, if I click on the checkbox and change it's value, the dataprovider variable never reflects the change!
I have been banging my head against the wall and cannot work this out. I have googled my heart out to no avail. Please save me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是因为 Flex 具有单向绑定,至少在 3.x 中是这样; Flex 4 将支持 2 向绑定。
您需要向复选框添加事件侦听器并修改侦听器中的变量。
PS:你是对的,这实际上是我今天回答的最简单的问题;)
That's 'cause Flex has one-way binding, at least in 3.x; Flex 4 will support 2-way binding.
You need to add an event listener to the CheckBox and modify the variable from the listener.
PS: You're right, this is in fact the easiest question I answered today ;)