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="yyyy"/>
        <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="11111111" />
        <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: [email protected]
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/
 



Reply via email to