简体   繁体   English

Flex TileList控件,图像加载问题

[英]Flex TileList control, image loading issue

I have a flex 3 TileList in wich a load several image (employee's headshot pictures). 我有一个flex 3 TileList,其中可以加载多个图像(员工的头像)。

The image I'm loading in the TileList are stored in a DataBase (I use the ByteArray class and a Base 64 encoding to store the images in the DB). 我在TileList中加载的图像存储在数据库中(我使用ByteArray类和Base 64编码将图像存储在DB中)。

When I load the images in the TileList from the DB, there is no problem they are displayed correctly, but when I scroll down in the TileList and scroll up again, the position of the images is changing, so for example the image in first position can be now in the 3rd and so on .... 当我从数据库中将图像加载到TileList中时,可以正确显示它们,但是当我在TileList中向下滚动并再次向上滚动时,图像的位置正在改变,例如,图像在第一位置现在可以排在第3位,依此类推....

Does somebody knows how to fix that ? 有人知道该如何解决吗?

Thanks in advance! 提前致谢!

PS : Here is the code of the ItemRenderer for the TileList PS:这是TileList的ItemRenderer的代码

private function init():void { img.load(data.imageData); 私有函数init():void {img.load(data.imageData); } }

]]> ]]>

The problem is that the list type components in Flex use renderer pooling (ie: when you scroll, the same renderers are reused for different items). 问题在于Flex中的列表类型组件使用渲染器池(即:滚动时,相同的渲染器可用于不同的项目)。 Since I guess you init method is only called on creationComplete or sometime at the start of the life cycle of the renderer, changing the data won't change the image. 由于我猜您的init方法仅在creationComplete上或在渲染器生命周期开始的某个时间调用,因此更改数据不会更改图像。

You could override set data instead 您可以改写设置数据

override public function set data(value:Object):void {
    super.data = value;
    if(value)
        img.load(value.imageData);
}

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

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