1 person found this helpful
The preferred way of passing vars between components is by using Data Active Objects (or Value Objects). These are then bound to a Custom Event Class which is then dispatched by Component A and handled by the main Application and passed into Component B.
If this concept is new to you, you might want to check out these video's... It may take a while to get your head round it but it will make sense once it 'clicks' with you. http://www.adobe.com/devnet/flex/videotraining/ - Start on Day with the video: Binding data between controls...
If you want to do direct binding (or accessing Global variables) which is usually considered bad practice then I think you'll need to create the public var myVar:String in both components and set each one to be [Bindable]. Then the two should update in each component and main application space.
public var myVar:String;
This is bad practice because you are tying together your components, when they should work independantly of each other without having to reach in and set/get the variables directly.
Hope this help...
You can communicate between the main app and components, and between components using "mx.core.Application.application" (or parentApplication and parentDocument), but that is considered bad practice, as it results in a tightly coupled application.
public var app:Object = mx.core.Application.application;
myComp1 = app.myComp2.myVar;
For a loosely coupled application, use custom events to pass data around. Here is my Flex cookbook post on using custom events in a MVC based wizard:
If this post answers your question or helps, please mark it as such.