apache-flex - 弹性 : Backgroundimage not showing in list

标签 apache-flex actionscript-3 flash-builder

我有一个带有背景图像的自定义组件。 但是当您通过 List 中的 ItemRenderer 生成此组件时,背景图像就消失了。

我做错了什么?

这是一张图片。第一个元素不是在列表中生成的,并且具有背景图像。其他三个是列表的一部分,没有背景图像。

enter image description here

这是列表的MXML代码

<mx:VBox>
    <solutionItems:displaySolutionItem  />  <!-- This element shows the background image -->                            
    <mx:List selectable="false"
         useRollOver="false" 
         id="listControllers" 
         backgroundAlpha="1"
         dataProvider="{controllers}" >
        <mx:itemRenderer>
            <fx:Component>      
                <solutionItems:displaySolutionItem /> <!-- These elements have nog background image -->                             
            </fx:Component>
        </mx:itemRenderer>
    </mx:List>      
</mx:VBox>

这是<solutionItems:displaySolutionItem />的代码

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas 
    xmlns:mx="http://www.adobe.com/2006/mxml"
    backgroundImage="{itemBackGround}"
    backgroundSize="100%">

    <mx:Script>
        <![CDATA[


            [Bindable]
            [Embed(source="assets/Components/ContainerBackgrounds/BoxBg.png", scaleGridLeft="5", scaleGridRight="50", scaleGridTop="5", scaleGridBottom="50")]
            private var itemBackGround:Class;


        ]]>
    </mx:Script>
    <mx:VBox
        paddingBottom="10"
        paddingLeft="10"
        paddingRight="10"
        paddingTop="10">        

        <mx:CheckBox id="chbControllerItem" label="NSL-4601" styleName="titleRed" />                    
        <mx:HBox>                       
            <mx:Image width="67" height="50" id="loader1" source="@Embed(source='assets/Components/ContainerBackgrounds/BoxBg.png')"/> 
            <mx:HBox>
                <mx:VBox>
                    <mx:Label text="Cube size" styleName="formLabel" height="12" />
                    <mx:Label text="Cube config" styleName="formLabel" height="12" />
                    <mx:Label text="Display res" styleName="formLabel" height="12" />
                    <mx:Label text="DPI" styleName="formLabel" height="12" />
                    <mx:Label text="Price" styleName="formLabel" height="12" />
                </mx:VBox>

                <mx:Box>
                    <mx:Label text="50''" height="12" />
                    <mx:Text text="2x3 (1224mm x 3264mm)" height="12" />
                    <mx:Label text="WXGA (1360x768)" height="12" />
                    <mx:Label text="72 dpi" height="12" />
                    <mx:Label text="€ 101.000,00" height="12" />
                </mx:Box>

            </mx:HBox>
        </mx:HBox>
    </mx:VBox>
</mx:Canvas>

这可能是一些小东西,但我找不到它。

最佳答案

以下内容将解决该问题:

  1. 从 itemRenderer 的 Canvas 元素中删除 backgroundImage="{itemBackGround}"

  2. 在 itemRenderer 类中的 VBox 之前添加以下内容。我测试了一下,效果很好:

    <mx:Canvas width="100%" height="100%" backgroundImage="{itemBackGround}" backgroundSize="100%"/>
    

如果您找到更好的方法,请务必更新您的问题以告知我们,

布莱恩

关于apache-flex - 弹性 : Backgroundimage not showing in list,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6110108/

相关文章:

actionscript-3 - 如何使用 ActionScript 和flex将变量值放入arraycollection中?

java - 在火星 Eclipse 中安装失败的 Flex 构建器

android - Flex (AIR) android Shoutcast 应用程序问题

apache-flex - 应用程序启动序列中的哪个事件适合触发在 AIR/Flex 中加载配置文件?

adobe air desktop 的多线程和响应能力

apache-flex - 类似于带有 HTML5 的 Adob​​e Flex 的框架

actionscript-3 - ActionScript 3 : Smooth programmatic animation

actionscript-3 - AS3-如何获取类的常量数组?

ios - 在没有苹果证书的情况下发布内置于 Flash Builder 4.5 中的 iOS 移动应用程序

apache-flex - Flex 本地化 : refresh DataProvider values