I'm using the same code base to compile different versions of a project. Each project has different base fonts. I've created multiple css files that use the same style names. The idea being that in the code I reference the style names, then the loaded CSS determines which font (and size, color, etc) is used for each style name.
The CSS files are compiling to SWFs, and those SWFs are referenced in config.xml files. Before compiling, I select the config file to use.
I am loading the CSS SWF files via the StyleManager in the Application.mxml, like so:
styleManager.loadStyleDeclarations( _contentData.elements( 'cssPath' ).@path )
The path traces out correctly as:
For some reasone I must include an fx:Style line in the Application.mxml file or no fonts are recognized. Example:
If I reference the css for project one (as done above) then most, but not all, styles work. Some styles reference the fonts from the project 1 css, others properly use fonts from project 2 swf. If I point to the CSS for the project I'm compiling in the <fx:Style > tag then all fonts work, but that defeats the goal of using XML rather than code to identify the styles.
So, why do I need the fx:Style line if the css is being loaded via StyleManager?
Why is there "cross talk" between style definitions?
Is there a better way to select styles at compile time?
I read this quickly so I might have missed a detail. I think your describing an issue with recent Flex releases that is described in the fine print somewhere. If you don't have any fonts embedded in the main app and are only bringing in fonts embedded in CSS SWFs, you have to force-link the EmbeddedFontRegistry by adding something like this to the main app's script block.
import mx.core.EmbeddedFontRegistry; EmbeddedFontRegistry;
(Yes, "EmbeddedFontRegistry" is in there twice, once to define the fully qualified name, the other to create a class dependency to force the linking).