1
votes

I have a List with his ItemRenderer, all right, when I send the data to dataprovider, this enter in the function 'set data' (override), I have there two images and one label, when the data is sent then I check if the image have the source that will set, if this item has that source, then I don't set the source for avoid a blink effect, but it is not working, why? in the condition I check the source of image and this is null.

Source:

override public function set data( _data:Object ) : void {
    if (imgStatusMessage.source != _data.source) {
        imgStatusMessage.source = _data.source;
    }
}

...

<s:Image id="imgStatusMessage" width="15" height="15" visible="false"/>

Then, when item is 'repaint' check property of this element, if have the same value of _data var, then don't set the value again.

EDIT: if more data is sent, all item work good, except first item; only the first item have this problem of blink in one of the images.

1
first thing I see that might give you weird results in you aren't calling the super... line 1 of that method should read super.data = _data; second you should always check for a valid value coming in.. so line 2 of that method should always read if(_data){ //do all other stuff }. Third suggestion is always have a final else that sets everything in the renderer back to null (or some default value) since renderers get recycled and could potentially have old data in them when they do. Try these and see if one fixes things for you. - Jason Reeves

1 Answers

0
votes

You can add this to your list definition(it will switch off renderers' recycling):

<s:List>
   <s:layout>
      <s:VerticalLayout useVirtualLayout="false" />
   </s:layout>
</s:list>

and see if problem persists.

If no, you can leave it like that, but it may influense app's performance for large lists. Otherwise, you may imlement your renderer in such way that it will not set source again, but instead will add already-made image from some pre-made collection, especially if 'source' is an url and not embedded BitmapAsset.