I re-read the original post, and it makes sense. I always use change events
rather than bindings on the way back from components, which is what I'd
recommend rather than two-way bindings. I'm interested to see how the SDK
team handles this with the bidirectional binding feature in 4.

Another approach, if you're set on binding: Rather than the "outer"
component waiting for creationComplete on the inner component to set the
model value, simply put code in the inner component that waits for
creationcomplete and creates the component->model "return" bindings
programmatically via BindingUtils.

Not sure I've explained that clearly tho, let me know if it's gibberish :)

-Josh

2009/3/17 Wesley Acheson <wesley.ache...@gmail.com>

>   My problem and I believe enrinne's problem is that when you have two way
> bindings on a ui control. The initial value of the control is set back in
> the model. I've seen this on textInput and comboBox.
>
> I can create a sample application but I think it would be very similar to
> the first post in the thread.
>
> I'd like to prevent the reverse binding occuring until the control is fully
> initialisaed.
>
> Regards,
>
> Wesley Acheson
>
>
>
> On Tue, Mar 17, 2009 at 3:35 AM, Josh McDonald <j...@joshmcdonald.info>wrote:
>
>>  I'm good with bindings, what's your specific problem? I didn't see
>> earlier any posts from you in this thread.
>>
>> -Josh
>>
>> 2009/3/17 Wesley Acheson <wesley.ache...@gmail.com>
>>
>>    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 <r...@cae.com> 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:* flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com]
>>>> *On Behalf Of *enriirne
>>>> *Sent:* Wednesday, March 11, 2009 8:25 AM
>>>> *To:* flexcoders@yahoogroups.com
>>>> *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
>>>>
>>>>
>>>>
>>>>
>>>
>>
>>
>> --
>> "Therefore, send not to know For whom the bell tolls. It tolls for thee."
>>
>> Josh 'G-Funk' McDonald
>>   -  j...@joshmcdonald.info
>>   -  http://twitter.com/sophistifunk
>>   -  http://flex.joshmcdonald.info/
>>
>>
>>
>>
>>
>  
>



-- 
"Therefore, send not to know For whom the bell tolls. It tolls for thee."

Josh 'G-Funk' McDonald
  -  j...@joshmcdonald.info
  -  http://twitter.com/sophistifunk
  -  http://flex.joshmcdonald.info/

Reply via email to