简体   繁体   English

如何动态设置Flex背景(颜色和图像)

[英]How to dynamically set Flex Background (Color and Image)

I want to give the users the ability to set the background color or choose image to make it background (Tile, Center and Strentch). 我想让用户能够设置背景颜色或选择图像使其成为背景(平铺,居中和突出显示)。 I tried couple of things with no luck such as trying to chaing a Skin object and assign it. 我没有运气就尝试了几件事,例如尝试追逐Skin对象并为其分配对象。 and tried something like: 并尝试了类似的方法:

FlexGlobals.topLevelApplication.setStyle("backgroundColor",uint(chosenColor));

with no luck. 没有运气。

Any ideas? 有任何想法吗?

Are you using Flex 3 Halo or Flex 4 Spark components? 您是否正在使用Flex 3 Halo或Flex 4 Spark组件?

I thought to access the top level application object, you had to cast it as an application object. 我以为要访问顶级应用程序对象,您必须将其强制转换为应用程序对象。 But, otherwise I would have used the exact same approach you use. 但是,否则我会使用与您完全相同的方法。

(FlexGlobals.topLevelApplication as Application).setStyle("backgroundColor",uint(chosenColor));

However, if you're using the Flex 4 approach, I would expect the background color to be in the Application skin class and am not sure if the style would affect that. 但是,如果您使用的是Flex 4方法,则我希望背景色在Application外观类中,并且不确定样式是否会影响它。 I haven't worked through the styling differences between skin classes and styles yet. 我还没有解决皮肤类别和样式之间的样式差异。 You may want to create a custom skin class that sets the background color based on the style in the component class. 您可能想要创建一个自定义外观类,该外观类根据组件类中的样式设置背景色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM