How do you dynamically load a CSS file into a Flex application?

前端 未结 4 825
无人共我
无人共我 2020-12-19 09:12

I know that you can apply CSS in order to style objects in Flex using the StyleManager:
http://livedocs.adobe.com/flex/3/html/help.html?content=styles_07.html

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-19 09:24

    In this comment to an issue related to this in the Adobe bug tracker T. Busser is describing what might be a viable solution for you:

    "I've created a small class that will 'parse' a CSS file read with an HTTPService object. It takes apart the string that is returned by the HTTPService object, break it down into selectors, and create a new CSSStyleDeclaration object for each selector that is found. Once all the properties are assigned to the CSSStyleDeclaration object it's added to the StyleManager. It doesn't perform any checks, you should make sure the CSS file is well formed, but it will be sufficient 99% of the time. Stuff like @font, Embed() and ClassReference() will hardly be used by my customers. They do need the ability to change colors and stuff like that so they can easily theme the Flex application to their house style."

    You could either try to contact this person for their solution or alternatively maybe use the code from this as3csslib project as a basis for writing something like what they're describing.

提交回复
热议问题