Several ways.
Application.application gives a reference to the top-level application
document scope. So from inside C2, you would do somthing like:
var app:Application = Application.application;
var myXML:XML = app.c1.mySourceXml; //assumes the instance of component
C1 has an id="c1"
parentDocument gives a reference to the immediate parent document (use
with nested components)
Or, you can pass a reference to anything into any component.
<mx:Application....
<ns:C1 id="C1"
<ns:C2 refToC1="{C1}" ...
The above requires a public property on C2 named "refToC1".
Tracy
________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of [EMAIL PROTECTED]
Sent: Wednesday, October 17, 2007 2:28 PM
To: [email protected]
Subject: [flexcoders] reference a component from somewhere else
Hi,
>From a component (ns:C2) containing a form, how can I reference an
embbeded xml declared in another component (ns:C1)
Using id of my xml (mysourceXml) I get an 1120 Error (Access of
undefined property) !!
_________________________
//in component C1:
....
<mx:Script>
<![CDATA[
[Bindable]
public var mysourceXml:XML =
<mainnode>
<user firstname="John" lastname="Doe"/>
<user firstname="Mary" lastname="Doe"/>
...
]]>
</mx:Script>
...
<mx:DataGrid id="usersGrid" dataProvider="{mysourceXml.user}"
<mx:columns>
<mx:DataGridColumn dataField="@firstname" headerText="First
Name"/>
<mx:DataGridColumn dataField="@lastname" headerText="Last Name"/>
...
</mx:columns>
</mx:DataGrid>
...
____________
...//in Component C2:
<mx:TextInput id="IDInput"
text="[EMAIL PROTECTED]" />
....
_________________________
Thx for your help !
Eric
Eric