I am having the following problem:
I have a Main application with a SWFLoader that loads a child Flex application. When a button is pressed, SWFLoader loads a new child Flex application. Currently LoaderContext for SWFLoader is created as follows:
var context:LoaderContext = new flash.system.LoaderContext(false, ApplicationDomain.currentDomain);
Everything seems to work okay except that CSS style sheets definded in the first child application cannot be overwritten by the CSS style sheets in the second.
After much research I see the following two options: 1. load style sheets externally using StyleManager.loadStyleDeclaration() method or 2. specify a different ApplicationDomain for the child Flex application.
The problem with solution #1 is I would like to keep all style sheets embedded in either the main application or each child application. So, my question is, how do load/reset CSS styles while keeping the CSS (or CSS compiled to SWF) embedded when StyleManager.loadStyleDeclaration() only takes a URL as a parameter?
The problem with solution #2 is as follows: when I change the ApplicationDomain property in the LoaderContext declaration to this:
var context:LoaderContext = new flash.system.LoaderContext(false, new ApplicationDomain(ApplicationDomain.currentDomain));
I get the following error when I load a second child application into the SWFLoader:
TypeError: Error #1034: Type Coercion failed: cannot convert spark.components::VScrollBar@64d6851 to spark.components.VScrollBar.
(See attached txt for full trace stack.)
I'm using Flex 4.0 beta 2 and Flash Builder beta 2.
Also, I found this article on per Module StyleManager which does not look like it has been implemented and is basically exactly what I'm trying to accomplish but with a SWFLoader instead ofModule.
If someone could please explain or point me in the right direction on how to either 1. load Flex 4 beta 2 application as a sub application domain app without generating VScollBar error (and if that will even solve overwriting CSS styles issue). or 2. how to load StyleManager.loadStyleDeclaration() from an embedded css or swf, I would greatly appreciate it.
Thank you in advance,
Try one of the nightly builds. Beta2 does not have the feature you referenced. Then nightly builds should. I would not set a LoaderContext and let it use the default.
Flex SDK Developer
Adobe Systems Inc.
Alex, thank you for the quick reply -- I'll give it a shot. Where would I find the nightly builds? I found the source code repository, but if there's a nightly build I can check out, that would be much easier.