Hi Abdul and Tracy, Thanks for the example.It works, but I was expecting an event driven model instead of binding to exchange data between components. Can the same be explained with broadcast/listener model?
Thanks, Mohanraj --- Abdul Qabiz <[EMAIL PROTECTED]> wrote: > Hi, > > You can achieve this by using Data Binding in Flex. > Did you look at binding? > > > You can bind two controls like this.. > > <mx:Application ..> > > <mx:ComboBox id="_cb" dataProvider="[{label:'India', > data:1}, {label:'USA', > data:2}]"/> > <mx:TextInput id="_ta" > text="{_cb.selectedItem.label}"/> > > </mx:Application> > > In above code, when combo box selection changes, > TextArea would be populated > with selected item's label. > > Please look at "Binding and Storing Data in Flex" > section Flex docs.. > http://livedocs.macromedia.com/flex/15/flex_docs_en/wwhelp/wwhimpl/js/html/w > whelp.htm?href=00000687.htm > > > Another quick-dirty example might give you an some > idea: > > > ##comp1.mxml### > > <mx:VBox > xmlns:mx="http://www.macromedia.com/2003/mxml"> > <mx:Script> > <![CDATA[ > > var dataProvider:Array; > var selectedItem:Object; > > ]]> > </mx:Script> > <mx:ComboBox id="_cb" dataProvider="{dataProvider}" > change="selectedItem = event.target.selectedItem;"/> > </mx:VBox> > > > ##comp2.mxml### > <mx:VBox > xmlns:mx="http://www.macromedia.com/2003/mxml"> > <mx:Script> > <![CDATA[ > > var textValue:String; > > ]]> > </mx:Script> > <mx:TextInput id="_ti" text="{textValue}"/> > </mx:VBox> > > ##main.mxml## > > <mx:Application > xmlns:mx="http://www.macromedia.com/2003/mxml" > xmlns="*"> > <mx:Script> > <![CDATA[ > > var dp:Array = [ > > {label:"Manish",data:2}, > {label:"Sam", > data:3}, > {label:"Abdul",data:1} > ]; > > ]]> > </mx:Script> > <comp1 id="cmp1" dataProvider="{dp}"/> > <comp2 id="cmp2" > textValue="{cmp1.selectedItem.label}"/> > > </mx:Application> > > > -abdul > > -----Original Message----- > From: Mohanraj Jayaraman > [mailto:[EMAIL PROTECTED] > Sent: Saturday, April 09, 2005 12:45 AM > To: flexcoders@yahoogroups.com > Subject: [flexcoders] Exchanging data between MXML > Components > > > Hi , > > I have two MXML components 'comp1' and 'comp2' in my > main application file 'main' > > <mx:application ... > > <comp1 id="cmp1" /> > <comp2 id="cmp2" /> > </mx:application> > > > 'Comp1' populates a combo box 'cmb' with the result > from RemoteObject call. > > Upon selecting an Item from combo box 'cmb', I > should > popualte a text box 'tbox' in 'Comp2' > Basically 'Comp2' is dependant on comp1. > Can someone explain me with a simple example on how > 'Comp2' text box can receive the combo box data > everytime the combo box selection has changed? > > Thanks, > Mohanraj > > > > > __________________________________ > Do you Yahoo!? > Yahoo! Personals - Better first dates. More second > dates. > http://personals.yahoo.com > > > > > Yahoo! Groups Links > > > > > > > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/