Hi Aman- This looks like a bug. Would you please log it in the bug base here: https://bugs.adobe.com/jira Thanks - Mac
On 10/17/07 2:23 AM, "cuddlygunchi" <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > 1) I bind the selectedItem property of a List component to a variable > > 2) View the value of that variable on "change" event for the List > > If the binding is performed by mx:Binding, on change event, the value > of the bound variable would be the latest value selected. > > However, if binding had been done using BindingUtils.bindProperty, > the value of the variable available on "change" would be the > previously selected value and not the latest, unlike the previous > case. > > Test Case: > > ------------------------------------------ > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > creationComplete="init()"> > <mx:Script> > <![CDATA[ > import mx.binding.utils.BindingUtils; > > [Bindable] > public var boundvar:Object; > > public function init():void > { > BindingUtils.bindProperty > (this, "boundvar", mylist, "selectedItem"); > } > ]]> > </mx:Script> > > <!-- <mx:Binding source="mylist.selectedItem" > destination="boundvar"/> > --> > <mx:Array id="granularity"> > <mx:Object label ="Item1"/> > <mx:Object label ="Item2"/> > <mx:Object label ="Item3"/> > <mx:Object label ="Item4"/> > </mx:Array> > <mx:List id="mylist" dataProvider="{granularity}" > labelField="label" change="trace(boundvar.label)"/> > > </mx:Application> > -------------------------------------- > > In the attached case, binding has been done via BindingUtils. It > would complain when you first select an item as the previous value of > the variable was null, even though it should have been populated by > the latest value via Binding before the change event is triggered. > Comment this and uncomment the mx:Binding line to observe the change > in behaviour. > > Flex Version: 2.0.1 > > Thanks, > Aman Thind > > --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , > "Alex Harui" <[EMAIL PROTECTED]> wrote: >> > >> > Binding should run first. Can you make a small test case? >> > >> > >> > >> > You can use callLater to delay processing. >> > >> > >> > >> > ________________________________ >> > >> > From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> > [mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> ] On >> > Behalf Of cuddlygunchi >> > Sent: Thursday, October 11, 2007 7:30 PM >> > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> >> > Subject: [flexcoders] Ensuring Bindings get executed before using > bound >> > variables >> > >> > >> > >> > Hi, >> > >> > I have a list component whose selectedItem is bound to a variable > in >> > my model. >> > >> > On "change" event i perform an action that expects the variable in > my >> > model to hold the new selectedItem in the list. However, it still >> > contains the old value at that time. Calling executeBindings before >> > my action did not help either. >> > >> > Is it that the change event is triggered before the bindings take >> > effect? What event should i use then? >> > >> > How can I force all bindings on a ui component to get executed > before >> > moving on to the next step that expects updated values? My bindings >> > exist both in actionscript as BindingUtils.bindProperty and in mxml >> > as mx:Binding. >> > >> > Many Thanks, >> > Aman >> > > > >