Question

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.

Was it helpful?

Solution

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 ;)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top