It will achieved by Application and Doccument object
Application object has the following characteristics:
* Application objects are MXML files with an <mx:Application> tag.
* Most Flex applications have a single Application object.
* The Application file is the first file loaded.
* An Application object is also a Document object.
* You can refer to the Application object as mx.core.Application.application from anywhere in the Flex application.
* If you load multiple nested applications by using the SWFLoader control, you can access the scope of each higher application by parentApplication.parentApplication, and so on.
Document object has the following characteristics:
* All MXML files that a Flex application uses are Document objects, including the Application object’s file.
* Custom ActionScript component files are Document objects.
* The Flex compiler cannot compile a SWF file from a file that does not contain an <mx:Application> tag.
* Documents usually consist of MXML custom controls that you use in your Flex application.
* You can access the scope of a document’s parent document by using parentDocument, parentDocument.parentDocument, and so on.
* Flex provides a UIComponent.isDocument property so that you can detect if any given object is a Document object.
Accessing Document and Application object scopes
mx.core.Application.application The top-level Application object, regardless of where in the document tree your object executes.
mx.core.UIComponent.parentDocument The parent document of the current document. You can use parentDocument.parentDocument to walk up the tree of multiple documents.
mx.core.UIComponent.parentApplication The Application object in which the current object exist
EXAMPLE:
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml”
xmlns:MyComps=”myComponents.*”
>
<mx:Script>
<![CDATA[
public function getSalutation():String {
return “Hi, ” + mylbl.text;
}
]]>
</mx:Script>
<mx:Label id=”mylbl” text=”Guys”/>
<!– Include the ButtonGetSalutation.mxml component. –>
<MyComps:ButtonGetSalutation/>
</mx:Application>
To access the mylbl(Label control) and call the getSalutation() method in your MXML components, you can use the application property, as the following example from the MyComponent.mxml component shows:
<?xml version=”1.0″?>
<!– containersapplicationmyComponentsButtonGetSalutation.mxml –>
<mx:VBox xmlns:mx=”http://www.adobe.com/2006/mxml” width=”100%” height=”100%”>
<mx:Script>
<![CDATA[
/* To refer to the members of the Application class,
you must import mx.core.Application. */
import mx.core.Application;
]]>
</mx:Script>
<mx:Label id=”myL”/>
<mx:Button label=”Click Me” click=”myL.text=Application.application.getSalutation();”/>
</mx:VBox>
Similarly use parentDocument.parentDocument.doSomething() for Document object.