Sorry, data binding is one-way.  You can use a mx:Binding tag to set up two-way pretty easily though.

 

Matt

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of tombaggett
Sent: Thursday, October 05, 2006 12:50 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Is data binding a one-way street from vars to component properties?

 

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>

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Software development tool Software development Software development services
Home design software Software development company

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

Reply via email to