如何将 CSS 文件动态加载到 Flex 应用程序中?
我知道您可以应用 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(这不是一个可行的选项)。 有没有办法解决?
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
You can also load compiled CSS files (SWFs) dynamically:
http://livedocs.adobe.com/flex/3/html/help.html?content=styles_10.html
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在此评论中,针对 Adobe 错误跟踪器中与此相关的问题T. Busser 正在描述对您来说可能可行的解决方案:
您可以尝试联系此人寻求解决方案,也可以使用 这个 as3csslib 项目 作为编写类似他们所描述的内容的基础。
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:
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.
编辑:此解决方案不起作用。 从解析器中取出的所有选择器都将转换为小写。 这可能适用于您的应用程序,但可能不会...
我将这个答案留在这里,因为它可能会帮助某些人寻找解决方案并警告其他人此方法的局限性。 >
请参阅我的问题:“寻找用 AS3 编写的 CSS 解析器”进行完整的讨论,但我发现标准库中隐藏了一个 CSS 解析器。 以下是如何使用它:
然后您可以使用以下方法应用样式:
Edit: This solution does not work. All selectors that are taken out of the parser are converted to lowercase. This may work for your application but it will probably not...
I am leaving this answer here because it may help some people looking for a solution and warn others of the limitations of this method.
See my question: "Looking for CSS parser written in AS3" for a complete discussion but I found a CSS parser hidden inside the standard libraries. Here is how you can use it:
You can then apply the styles using:
Flex 中 CSS 的应用是在编译时在服务器端处理的,而不是在运行时在客户端处理的。
我会为您看到两个选项(我不确定这两个选项有多实用):
祝你好运。
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):
Good luck.