如何在 Flex 3.5 应用程序中在运行时更改应用程序背景颜色?
我有一个 Flex 3.5 应用程序,它将用于多种用途,作为我想要进行的视觉更改的一部分,以指示应用程序所处的模式,我想更改其背景颜色。
目前,应用程序标记如下所示:
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:com="ventures.view.component.*"
xmlns:views="ventures.view.*"
layout="absolute"
preinitialize="onPreInitialize()"
creationComplete="onCreationComplete()"
applicationComplete="onApplicationComplete()"
click="onClick(event)"
enabled="{(!chainController.generalLocked)}"
backgroundGradientColors="[0xFFFFFF, 0xFFFFFF]"
>
我尝试使用绑定,对于 backgroundColor
和 backgroundGradientColors
属性:
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
...
backgroundColor="{app_background_color}"
>
-and-
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
...
backgroundGradientColors="{app_background_color}"
>
但对于前一个绑定是不允许的,对于后者有一个警告:
数据绑定将无法检测对“app_background_color”的分配。
我还遇到了此页面,这似乎表明我可以做使用 setStyle()
方法,但是 文档似乎表明此方法仅适用于组件,而不适用于主画布。
我想我可以专门为此目的将所有内容包装在
中,但这似乎很浪费 - 就像 HTML 中的 Div-itis 之类的。
在运行时更改主应用程序背景颜色的最佳方法是什么?
I have a Flex 3.5 application that will serve multiple purposes, and as part of the visual changes that I'd like to make to indicate which mode the application is in, I want to change its background color.
Currently, the application tag looks like this:
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:com="ventures.view.component.*"
xmlns:views="ventures.view.*"
layout="absolute"
preinitialize="onPreInitialize()"
creationComplete="onCreationComplete()"
applicationComplete="onApplicationComplete()"
click="onClick(event)"
enabled="{(!chainController.generalLocked)}"
backgroundGradientColors="[0xFFFFFF, 0xFFFFFF]"
>
I've tried using a binding, for both the backgroundColor
and backgroundGradientColors
attributes:
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
...
backgroundColor="{app_background_color}"
>
—and—
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
...
backgroundGradientColors="{app_background_color}"
>
but for the former binding is not allowed, and for the latter there is a warning that:
Data binding will not be able to detect assignments to "app_background_color".
I also ran across this page which seems to indicate that I could do it with the setStyle()
method, but the documentation seems to indicate that this method is only available for components, not the main canvas.
I suppose I could wrap everything in a <mx:Canvas></mx:Canvas>
specificially for this purpose, but that seems wasteful—like Div-itis in HTML or something.
What's the best way to change the main application background color at run-time?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来如果您的 mx:Application 标记使用 backgroundColor 属性,您需要执行以下操作:
It looks like if your mx:Application tag uses the backgroundColor attribute you need to do this: