RE: [flexcoders] Exchanging data between MXML Components
This works. Thanks a ton for the example Abdul. Mohanraj --- Abdul Qabiz [EMAIL PROTECTED] wrote: Hi Mohanraj, It's very much possible, I have modified the previous example to dispatch eventsIt would give you some idea, how you can achieve the same. I am using Metadata tag for mxml components, you can find more about in docs. ##main.mxml### mx:Application xmlns:mx=http://www.macromedia.com/2003/mxml; xmlns=* mx:Script ![CDATA[ var dp:Array = [ {label:Abdul,data:1}, {label:Manish,data:2}, {label:Sam, data:3} ]; function startListening() { //you can also subscribe to change event of comp1 on this way... cmp1.addEventListener(change, mx.utils.Delegate.create(this, onCMP1Change)); } function onCMP1Change(event) { cmp2.textValue = event.target.selectedItem.label; } ]] /mx:Script !-- you can assign event handlers to change attribute also. Following lin is commented now../-- !-- comp id=cmp1 dataProvider={dp} chnage=onCMP1Change(event);/ /-- comp1 id=cmp1 dataProvider={dp}/ comp2 id=cmp2 creationComplete=startListening(); / /mx:Application ##comp1.mxml### mx:VBox xmlns:mx=http://www.macromedia.com/2003/mxml; mx:Metadata !-- this tells the compiler to embed relevant code, so that you can broadcast 'change' event /-- [Event(change)] /mx:Metadata mx:Script ![CDATA[ public var dataProvider:Array; public var selectedItem:Object; //call this function from change handler of combobox and this function dispatches the change event.. function onSelectionChange(event) { selectedItem = event.target.selectedItem; dispatchEvent({type:'change'}); } ]] /mx:Script mx:ComboBox id=_cb dataProvider={dataProvider} change=onSelectionChange(event);/ /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 About Metadata tag: http://livedocs.macromedia.com/flex/15/flex_docs_en/0459.htm Hope that helps... -abdul -Original Message- From: Mohanraj Jayaraman [mailto:[EMAIL PROTECTED] Sent: Saturday, April 09, 2005 4:13 AM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Exchanging data between MXML Components 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=0687.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 === message truncated === __ 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
[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 * 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/
RE: [flexcoders] Exchanging data between MXML Components
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=0687.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 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/
RE: [flexcoders] Exchanging data between MXML Components
Here are an application file and two components that demonstrate binding between components: ** BindBetweenComponents.mxml ** ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.macromedia.com/2003/mxml; xmlns=* mx:Script![CDATA[ public var sTest:String = TestString; ]]/mx:Script mx:Panel mx:Label text=I am Test field (on the application level) / mx:TextInput id=tiTest text=/ BindBetweenComponents1 id=child1 height=180 title=Component1 app={this} / BindBetweenComponents2 id=child2 height=180 siblingInput1={child1.myinput1} title=Component2/ /mx:Panel /mx:Application ** BindBetweenComponents1.mxml ** ?xml version=1.0 encoding=utf-8? mx:Panel xmlns:mx=http://www.macromedia.com/2003/mxml; width=400 height=400 mx:Script![CDATA[ public var app:BindBetweenComponents = null; public var testControl:mx.controls.TextInput = null; ]]/mx:Script mx:Label text=Change me, and see the field in Component2 change / mx:TextInput id=myinput1 text= / mx:Label text=I am bound to the Test field on the application / mx:TextInput id=txtAppVar text={app.tiTest.text} / /mx:Panel ** BindBetweenComponents2.mxml ** ?xml version=1.0 encoding=utf-8? mx:Panel xmlns:mx=http://www.macromedia.com/2003/mxml; width=400 height=400 mx:Script![CDATA[ public var siblingInput1:mx.controls.TextInput; ]]/mx:Script mx:Label text=I am bound to the first field on Component1 / mx:TextInput id=myinput2 text={siblingInput1.text} / /mx:Panel -Original Message- From: Mohanraj Jayaraman [mailto:[EMAIL PROTECTED] Sent: Friday, April 08, 2005 3:15 PM 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 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/
RE: [flexcoders] Exchanging data between MXML Components
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=0687.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/