gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 06:52:48 24 4
gpt4 key购买 nike

嗨,我有一个带有 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 都是空的。

为什么会这样?

最佳答案

我将 Class FotoItem 中数据的 Datatype 从 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com