Flex TileList control, image loading issue
I have a flex 3 TileList in wich a load several image (employee's headshot pictures).
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).
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 firs开发者_JAVA百科t position can be now in the 3rd and so on ....
Does somebody knows how to fix that ?
Thanks in advance!
PS : Here is the code of the ItemRenderer for the TileList
private function 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). 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.
You could override set data instead
override public function set data(value:Object):void {
super.data = value;
if(value)
img.load(value.imageData);
}
精彩评论