0 Replies Latest reply on Feb 15, 2012 3:39 PM by CrookedGrin

    Loading css .swf at runtime in AIR app, styles not applied to subcomponents

    CrookedGrin Level 1

      I'm loading an external css document, compiled into a swf, into my AIR app at runtime (the app is compiled against Flex 4.1 SDK).  The external stylesheet overrides a bunch of embedded styles, including background colors, embedded images, etc.  If I load the css swf in a handler for the application's initialize event, it usually works fine, except sometimes -- apparently on slower machines -- the application's creation complete handler gets called before the css is done being parsed, and the initial view state that's shown does not reflect the styles from the external css swf.  The external css is definitely being found and loaded, because images embedded in the external css swf show up correctly, and those views that have already been instantiated when the stylesheet is loaded do show the external styles correctly.  But components that haven't been instantiated yet (because they're only included in subsequent view states) seem to ignore the new styles from the external css and instead use the original embedded styles.  This is only if the stylesheet is loaded in after the application has hit creation complete; if the css is loaded before the application has finished creation, the subcomponents seem to inherit the external styles correctly. 


      My understanding was that, if you load an external stylesheet swf that contains styles that override existing styles, components that use those styles should automatically use the new styles, without any action on my part. I've tried a number of techniques to force components to refresh their styles (calling invalidateDisplayList(), calling styleChanged(null), etc.), but I can't seem to get the subcomponents to recognize that their styles are stale and should be overridden by the newly-loaded styles from the external css.  Does anyone know how to force all components to refresh their styles, aside from just flagging them as invalid?