弹性+复选框 +数据提供者...很可能是您今天要回答的最简单的问题

发布于 2024-08-19 14:57:52 字数 728 浏览 3 评论 0原文

也许我昨​​晚没睡够,但我遇到了一个奇怪的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

或十年 2024-08-26 14:57:52

这是因为 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 ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文