views:

476

answers:

1

Hey All,

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.

+2  A: 

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

Leo Jweda
Here's a way to do 2 way binding, it seems like just a more complicated way of Laith's suggestion, but it might shed more light on the issue. http://opensource.adobe.com/wiki/display/flexsdk/Two-way+Data+Binding
invertedSpear
Thank you sir, you are a gentlemen and a scholar.
Chase B. Gale