Flex + CheckBox + Dataprovider... quite possibly the easiest question you will answer today
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.
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 ;)
精彩评论