I expected that binding a data variable to a UI
component would result
in (a) the UI component being automatically initialized using the
variable's value and (b) the variable's value being changed to reflect
the UI component's current state whenever that state changed.
The accompanying example doesn't work that way. The variables aren't
updated as the HSlider and DateChooser values are changed. However,
changing one UI component's setting results in the bound variable
being updated while another doesn't in my production code.
What is the expected behavior? Is there a bug in the Flex data
binding mechanism? It appears to be flaky.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
>
<mx:Script>
<![CDATA[
[Bindable]
public var numTest:Number = 1;
[Bindable]
public var dateTest:Date = new Date("Feb 1 2005");
public function sliderChanged(event:Event):void {
trace("slider value = " + numTest);
}
public function dateChanged(event:Event):void {
trace("date value = " + dateTest.toDateString());
}
// The trace statements always indicate the
// variables' values remain unchanged.
]]>
</mx:Script>
<mx:HSlider x="10" y="10" minimum="0"
maximum="10" value="{numTest}"
change="sliderChanged(event)"/>
<mx:DateChooser x="10" y="30" selectedDate="{dateTest}"
change="dateChanged(event)"/>
</mx:Application>