嗨,我有一个带有 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/