Loading a sub-application in same application domain as main app sibling
Hi,
I am creating a portal application which loads applications in their own application domain different from the main app. Basically what I am trying to do is the following:
-Portal -- Main ApplicationDomain
- SubApp1 - new AppDomain
- SubApp2 - same AppDomain as SubApp1
SubApp1 and SubApp2 could then call each other's properties and change their values.
I tried the following:
var loaderContext:LoaderContext = new LoaderContext();
loaderContext.securityDomain = SecurityDomain.currentDomain;
loaderContext.applicationDomain =
new ApplicationDomain();//new app domain
//--SubApp1
swfLoader1SubApp1 =
new SWFLoader();
swfLoader1SubApp1.loaderContext =loaderContext;
panel1.addChild(swfLoader1SubApp1);
//--SubApp2
swfLoader2SubApp2 =
new SWFLoader();
swfLoader2SubApp2 .loaderContext = swfLoader1SubApp1.loaderContext;
panel2.addChild(swfLoader2SubApp2);
When I try to change values in each other's values, only SubApp1 one can change the value of the property on SubApp2. SubApp2 gives me an error as follows when accessing SubApp1 property:
ReferenceError: Error #1069: Property treeTitle not found on SubApp2 and there is no default value.
I am trying have them reference each other's propertie's as follows:
//SubApp2 calling SubApp1 --- DOES NOT WORK -- GIVES ABOVE ERROR
public function setLabel():void //some function that gets called when a button is clicked on SubApp2
{
Application.application.treeTitle.text =
"dummy value"; //treeTitle is a member of SubApp1
}
The other way around works: SubApp1 calling SubApp2 -- THIS WORKS FINE
// Event handler for the Tree control change event.
public function treeChanged(event:Event):void {
selectedNode=Tree(event.target).selectedItem
as XML;
Application.application.titleBar.text = selectedNode.@label;
}
What am I doing wrong? Any ideas are greatly appreciated 🙂
Thank you.
