Yeah, as you've discovered, data-binding in Flex is only one-way. The recommended technique is to create an <mx:Binding> tag for the other direction instead of creating a "change" handler as you did. It's unfortunate in my opinion, but that's what you have to do. At least it's not a ton of coding, though.
By the way, since you (correctly) put [Bindable] on your data, your code will work even if you don't explicitly dispatch the propertyChange event. - Brian Morearty Intuit --- In [email protected], "tsiesser" <[EMAIL PROTECTED]> wrote: > > Flex is a lovely thing. I've managed to do some quite advanced tricks > using item renderers, datagrid extensions, and rotating images, and > yet I find myself confused by something very basic. Perhaps data > binding just doesn't do what I expect! Or hopefully, I'm just doing it > wrong and some kind person here can set me straight. :-) > > It seems that when I bind a property to a component, the component is > easily updated whenever the property changes - but the opposite > doesn't happen. If the component changes, it doesn't automatically > update the original bound value (unless I explicitly perform the > update myself in an event handler). > > Say we have the following code: > > <mx:Script> > <![CDATA[ > private var _mytext:String; > > [Bindable] > public function get mytext():String > { > return _mytext; > } > > public function set mytext(value:String):void > { > _mytext = value; > dispatchEvent(new Event("propertyChange")); > } > ]]> > </mx:Script> > > <mx:Label text="Enter text:"/> > > <mx:TextInput id="txt" text="{mytext}"/> > > > With this code, any change to mytext will update the TextInput > control. But if the user types something into the control, mytext is > not updated... > > It seems I have to force the binding to be two-way by adding an event > handler to the TextInput component: > > <mx:TextInput id="txt" text="{mytext}" change="mytext=txt.text"/> > > > Is this really necessary? Is there any other way to force the binding > to be bidirectional?? > > All help and advice appreciated! > > --Tracey >

