如何将 CSS 文件动态加载到 Flex 应用程序中? [英] How do you dynamically load a CSS file into a Flex application?

查看:32
本文介绍了如何将 CSS 文件动态加载到 Flex 应用程序中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

You can also load compiled CSS files (SWFs) dynamically:
http://livedocs.adobe.com/flex/3/html/help.html?content=styles_10.html

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

However, I'm dynamically creating my CSS files using a web GUI and a server-side script. If the CSS is changed, then the script would also need to compile the CSS into an SWF (which is not a viable option). Is there any way around this?

推荐答案

CSS 在 Flex 中的应用在编译时在服务器端处理,在运行时不在客户端处理.

The application of CSS in Flex is handled on the server side at compilation and not on the client side at run time.

那么我会为您看到两个选项(我不确定两者是否实用):

I would see two options then for you (I'm not sure how practical either are):

  1. 使用服务器端脚本将您的 CSS 编译为 SWF,然后动态加载它们.
  2. 解析 CSS 样式表并使用 flex 中的 setStyle 函数来应用样式.与此方法类似的示例是 Flex 样式资源管理器,您可以在其中查看来源.
  1. Use a server side script to compile your CSS as a SWF then load them dynamically.
  2. Parse a CSS Style sheet and use the setStyle functions in flex to apply the styles. An similar example to this approach is the Flex Style Explorer where you can check out the source.

祝你好运.

这篇关于如何将 CSS 文件动态加载到 Flex 应用程序中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆