Fix for Ely’s SuperImage

SuperImage does not abort previous loads in it’s internal Loader. This means those Loader’s no longer have IOErrorEvent handlers. If you do have a case where the image fails to load after you’ve attempted to load a second image, this’ll cause an uncaught exception. This can happen when SuperImage is used within an itemRenderer where multiple image requests can occur during scrolling.

The fix is to ensure all previous Loader’s are closed before starting a new one, just like the mx.controls.Image does. Around line 105 of qs.controls.SuperImage, change this:

if(_content is Loader)
{
        Loader(_content).contentLoaderInfo.removeEventListener(Event.COMPLETE,loadCompleteHandler);
        Loader(_content).contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,loadErrorHandler);
        Loader(_content).contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, loadProgressHandler);
}

To this:

if(_content is Loader)
{
        Loader(_content).contentLoaderInfo.removeEventListener(Event.COMPLETE,loadCompleteHandler);
        Loader(_content).contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,loadErrorHandler);
        Loader(_content).contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, loadProgressHandler);
        try
        {
                Loader(_content).close();
        }
        catch(err:Error){}
}

 

2 Replies to “Fix for Ely’s SuperImage”

Comments are closed.