Let's say I have two containers (Container1=application , Container2). Container1 gets some data from user, perform some database lookup and displays Container2 with the results from database lookup.
Container1 --(call and display)--> Container2
Below shows how I am using a bindable variable in Container1 to pass the data from Container1 to Container2. Also shows how I display Container2 from Container1.
<!-- Container1 -->
[Bindable] public var foo:String = "bar";
private function loginHandler(event:LoginEvent):void
mycontainer2 = new Container2();
mycontainer2.name = "mycontainer2";
I am accessing the data in Container2 as follow:
<!-- Container2 -->
Q1) Is there a better way to pass data from one container to another and access the data?
Q2) Is this the only way to call and display Container2 from Container1?
Q3) How can I move back to Container1 from Container2, i.e. Container2 call and display Container1
Container2 --(back to)--> Container1
Best practices call for using custom events to share data between components. Here is my Flex 3 Cookbook post on the topic:
To switch easily between containers 1 & 2 use a ViewStack, the gold standard for such interaction, and manipulate the selectedIndex or selectedChild property:
If this post answered your question or helped, please mark it as such.