css - 如何将 CSS 文件动态加载到 Flex 应用程序中?

标签 css apache-flex dynamic-css

我知道您可以应用 CSS 以便使用 StyleManager 为 Flex 中的对象设置样式:
http://livedocs.adobe.com/flex/3/html/help.html?content=styles_07.html

您还可以动态加载已编译 CSS 文件 (SWF):
http://livedocs.adobe.com/flex/3/html/help.html?content=styles_10.html

但是,我正在使用 Web GUI 和服务器端脚本动态创建我的 CSS 文件。 如果更改了 CSS,则脚本还需要将 CSS 编译成 SWF(这不是一个可行的选项)。有什么办法解决这个问题吗?

最佳答案

this comment在 Adob​​e 错误跟踪器 T 中解决与此相关的问题。 Busser 正在描述对您来说可能是可行的解决方案:

"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."

您可以尝试联系此人寻求解决方案,也可以使用 this as3csslib project 中的代码作为编写类似他们所描述内容的基础。

关于css - 如何将 CSS 文件动态加载到 Flex 应用程序中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/204924/

相关文章:

xml - 如何在 flex/actionscript 中通过属性名称/值查找特定的 xml 数据

css - 如何更改文本框中选定文本的背景颜色?

css - 使元素等高并指定它们在 CSS 中的哪一列?

javascript - 有没有办法阻止页面特定部分的滚动?

javascript - 将 div absolute 定位在 td 中在 firefox 中不起作用

apache-flex - Flex 4 - 当容器的子级依赖于状态时如何循环它们

apache-flex - 如何使用 Parsley MVC IOC 注入(inject)动态连接 Starling View

html - 根据宽度设置为 auto 的其他 div 的 clientwidth 调整目标 div 的大小

javascript - 有没有办法使用 CSS 或 javascript 从另一个 CSS 样式引用现有的 CSS 样式?

jquery - 根据页面宽度实时更改 CSS