Sorry for resurecting an old thread. I've reciently given up on this.  I've
gone back to using event listeners.  It seems more reliable.  The problem as
I see it is that the binding events happen for any old reason. The change
events only seem to be triggered on user interaction which is much better
IMHO.

Regards,

Wesley Acheson

On Wed, Mar 11, 2009 at 3:42 PM, Yves Riel <[email protected]> wrote:

>  The problem you are experiencing is caused by the fact that when the
> player executes the line [ mf.foo = "bar" ], your text input is not even
> created in your form yet. So, the foo->myText binding does nothing and when
> the text input is finally created, the myText->foo binding executes and thus
> overwrite what was in foo.
>
> If you want to avoid this, you need to do:
>
> protected var mf:MyForm = new MyForm();
> mf.addEventListener(FlexEvent.CREATION_COMPLETE, formCreatedHandler);
> addChild(mf);
>
> protected function formCreatedHandler(event:FlexEvent):void {
>     mf.removeEventListener(FlexEvent.CREATION_COMPLETE,
> formCreatedHandler);
>     mf.foo = "bar";
> }
>
>  ------------------------------
> *From:* [email protected] [mailto:[email protected]] *On
> Behalf Of *enriirne
> *Sent:* Wednesday, March 11, 2009 8:25 AM
> *To:* [email protected]
> *Subject:* [flexcoders] Question about binding and circular reference
>
>  Say I have this:
>
> // MyForm.mxml
> [Bindable]
> public var foo:String;
>
> <mx:Bindable source="foo" destination="myText.text"/>
> <mx:Bindable source="myText.text" destination="foo"/>
>
> <mx:TextInput id="myText"/>
>
> Is there an elegant way to avoid that foo is cleared upon creation of
> MyForm?
> Indeed, if I do this in the main app:
>
> var mf:MyForm = new MyForm();
> mf.foo = "bar";
> addChild(mf);
>
> then myText is empty, probably because it's empty content is first assigned
> to foo due to the second binding.
> The real problem I'm trying to solve is to use the same value object to
> show data to the user and to receive his/her changes.
>
> Of course it works if I use two vos: say voIn and voOut, binding them
> accordingly.
>
> Any ideas?
>
> Enri
>
>
>
> 
>

Reply via email to