简体   繁体   English

Flex 4如何将背景图像设置为VBox?

[英]Flex 4 How to set background image to VBox?

I'm trying to use simple css rules as we do it in html to customize my app style but even simple 我正在尝试使用简单的CSS规则,就像我们在html中那样来自定义我的应用程序样式,但即使简单

.VBoxStyle{
    background-image:Embed("images/background.png"); 
}

doesn't work. 不起作用。 I read about many different situations based on old-new flex versions but couldn't understand anything. 我阅读了许多基于旧版Flex版本的不同情况,但一无所知。 So how do you change simple container background-image in flex mx? 那么,如何在flex mx中更改简单的容器背景图像?

The problem is that Flex 4 components use the Spark theme to define their appearance by default and in this theme border hasn't backgroundImage property. 问题是Flex 4组件默认情况下使用Spark主题定义其外观,并且在该主题边框中没有backgroundImage属性。 But you can change theme to halo and it will works. 但是您可以将主题更改为光晕,并且可以使用。 To change theme write in the additional compiler arguments: 要更改主题,请在其他编译器参数中写入:

-theme=${flexlib}/themes/Halo/halo.swc

It can be done with any of the Flex 3 container classes (VBox, HBox, Canvas, etc). 可以使用任何Flex 3容器类(VBox,HBox,Canvas等)完成此操作。

I'm typing this on a phone, so instead of a working example I defer to this useful blog post from one of the Flex SDK QA Engineers: 我在电话上键入此内容,因此我不参考一个有效的示例,而是参考其中一位Flex SDK质量检查工程师的有用博客文章:

http://blog.flexexamples.com/2008/01/05/changing-a-vbox-containers-background-image-attachment-in-flex/ http://blog.flexexamples.com/2008/01/05/changing-a-vbox-containers-background-image-attachment-in-flex/

That shows how to do it in MXML, but you should also be able to do it with CSS. 这说明了如何在MXML中执行此操作,但是您也应该可以使用CSS进行操作。

It's not clear why it's not working in your case. 目前尚不清楚为什么它不适用于您的情况。 In Flex I tend not to use hyphens in style property names (backgroundImage instead of background-image). 在Flex中,我倾向于在样式属性名称(backgroundImage而不是background-image)中不要使用连字符。

Also, were you trying to apply that style to all VBox's? 另外,您是否试图将这种样式应用于所有VBox? Or applying to specific VBox's with the styleName property? 还是使用styleName属性应用于特定的VBox?

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

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