apache-flex - 带有图像的 Flex List ItemRenderer 在滚动时丢失 BitmapData

标签 apache-flex flash data-binding list itemrenderer

嗨,我有一个带有 DataProvider 的 mx:List。如果 FotoItems 则此数据提供程序是一个 ArrayCollection

public class FotoItem extends EventDispatcher
{
    [Bindable]
    public var data:Bitmap;
    [Bindable]
    public var id:int;
    [Bindable]
    public var duration:Number;

    public function FotoItem(data:Bitmap, id:int, duration:Number, target:IEventDispatcher=null)
    {
        super(target);
        this.data = data;
        this.id = id;
        this.duration = duration;
    }
}

我的 itemRenderer 看起来像这样:

<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:fx="http://ns.adobe.com/mxml/2009" 
            xmlns:s="library://ns.adobe.com/flex/spark" 
            xmlns:mx="library://ns.adobe.com/flex/mx" >
<fx:Script>
    <![CDATA[
        import mx.collections.ArrayCollection;
    ]]>
</fx:Script>

<s:Label text="index"/>
<mx:Image source="{data.data}" maxHeight="100" maxWidth="100"/>
<s:Label text="Duration: {data.duration}ms"/>
<s:Label text="ID: {data.id}"/>

</mx:VBox>

现在,当我滚动时,离开屏幕的所有图像都会消失:( 当我查看 arrayCollection 时,每个项目的 BitmapData 均为 null。

为什么会这样?

最佳答案

我将 FotoItem 类中数据的数据类型从 Bitmap 更改为 BitmapData

在 ItemRenderer 中我执行以下操作:

override public function set data( value:Object ) : void {
            super.data = value;
            pic.source = new Bitmap(value.image);
        }

现在可以了。不知道为什么它不能使用位图

关于apache-flex - 带有图像的 Flex List ItemRenderer 在滚动时丢失 BitmapData,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2876760/

相关文章:

android - 如何从 Flex Mobile 中的另一个应用程序调用一个应用程序

apache-flex - validateProperties() 和 invalidateProperties() 之间的区别

html - 在 Flex 中显示 HTML 的最佳方式是什么?

java - 停止 Java 在上传时返回错误

c# - 使用 InteractiveDataDisplay.WPF 导出图形

apache-flex - 在 Adob​​e Flex 中将数据写入文本文件

java - 将 .swf 文件嵌入到我的 Jframe 中

apache-flex - 是否可以在 Flash Builder bin-debug 中嵌套文件夹

data-binding - 在 openUI5 的 csv 导出中删除不需要的换行符

c# - 文本框 MVVM 数据绑定(bind)