Ok, some progress. If I define the binding in ActionScript before adding it to
its parent container, it works halfway; meaning the second binding works, but
not the first one. It's not 2-way.
Here's the updated AS code:
var innerHBox:HBox = new HBox();
var dtc_acm:AutoCompleteModified = new AutoCompleteModified();
dtc_acm.dataProvider = data2;
dtc_acm.labelField = 'id';
BindingUtils.bindProperty( dtc_acm,'selectedIndex',cp_acm,'selectedIndex' );
var cp_acm:AutoCompleteModified = new AutoCompleteModified();
cp_acm.dataProvider = data2;
cp_acm.labelField = 'name';cp_acm.width = this.CP1.width;
BindingUtils.bindProperty( cp_acm,'selectedItem',dtc_acm,'selectedItem' );
innerHBox.addChild( dtc_acm );
innerHBox.addChild( cp_acm );
Why did the position of the code matter? Why is it only 1-way binding? Still a
little confused as to these things.
Thanks for listening,
Matt
--- In [email protected], "Matthew" <fume...@...> wrote:
>
> Hi -
>
> I'm binding two AutoCompleteModified objects to one another; meaning you type
> in one and it selects the correct object in the other. It works fine when I
> define it in MXML:
>
> <comp:AutoCompleteModified
> id="DTC1"
> dataProvider="{data1}"
> labelField="id"
> selectedIndex="{CP1.selectedIndex}">
>
> <comp:AutoCompleteModified
> id="CP1"
> dataProvider="{data1}"
> labelField="name"
> selectedItem="{DTC1.selectedItem}" />
>
> However, a user can add a new row to a Grid and then I set up the binding and
> objects via actionscript and it errors out:
>
>
> var dtc_acm:AutoCompleteModified = new AutoCompleteModified();
> dtc_acm.dataProvider = data2;
> dtc_acm.labelField = 'id';
>
> myGridItem.addChild( dtc_acm );
>
> var cp_acm:AutoCompleteModified = new AutoCompleteModified();
> cp_acm.dataProvider = data2;
> cp_acm.labelField = 'name';
>
> myGridItem.addChild( cp_acm );
>
> BindingUtils.bindProperty( dtc_acm,'selectedItem',cp_acm,'selectedItem' );
> BindingUtils.bindProperty( cp_acm,'selectedIndex',dtc_acm,'selectedIndex' );
>
> The error I get is thrown by the ChangeWatcher.as class and it says the
> exceptions are being thrown by the getter in the host object. However, if I
> only set 1 binding (instead of 2), it works.
>
> I don't understand what may be happening here. Can anyone see any potential
> problems in my code?
>
> Thank you kindly for any helpful tips,
>
> Matt
>