Situation: I load flex sub-application into the main application through the default SWFLoader. The sub-application is loaded into the separate ApplicationDomain and SWFLoader's trustContent is set to false.
Question: Is it possible to get a child component (element) from the sub-application and add it to the main application? If it is possible, how would I do this? If not please post the ideas or alternative ways.
Thanks in advance.
If you are loading into a sibling ApplicationDomain then no, you can’t directly parent Flex components from the sub-app in the main app. The SWFLoader should be able to show the components as children of the SWFLoader.
We might need more info about the scenario. If you are using a Marshall Plan config, for example, the sub-app can put up a popup dialog over the main app.
The key principles are that for a Flex app, a UIComponent must be parented by another UIComponent, and a Flex container’s children must implement IUIComponent. When you have sibling ApplicationDomains, it is essentially impossible to fulfill those requirements. Since a UIComponent’s children can be any sort of display object, then I suppose you could create custom wrappers for the sub-apps UIComponents, but the first principle would still be broken and while you might be able to hack around that, lots of other things like styles, invalidation/validation timing and focus might be broken.
The main application and the sub-app are compiled with the same version of Flex, so that they share the same class definitions.
|var liveTile:LiveThumb = liveTiles[i] as LiveThumb;|
|var container:BorderContainer = new BorderContainer();|
|container.width = 64;|
|container.height = 64;|
LiveThumb is just a modified BorderContainer. The new BorderContainer is displayed, but its contents - isn't.