Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Shakespeare87

Bug On ImageLoader

Recommended Posts

var imgLoader:ImageLoader = new ImageLoader("data/img/global_ui/blue/ButtonStd1.jpg", {onComplete : onComplete});

var imgLoader2:ImageLoader = null;

 

imgLoader.load();

var tempBD:BitmapData = null;

 

function onComplete(evt:LoaderEvent):void{

tempBD = imgLoader.rawContent.bitmapData;

tempBD.dispose();

// imgLoader.dispose(true); 

imgLoader2 = new ImageLoader("data/img/global_ui/blue/ButtonStd1.jpg", {onComplete : onComplete2});

imgLoader2.load();

}

 

function onComplete2(evt:LoaderEvent):void{

trace(imgLoader2.rawContent.bitmapData.height);

}

 

If I comment dispose(true), onComplete2 will give and error. GreenSock ImageLoader does not check if the bitmapData is being disposed or not before sending.

Link to post
Share on other sites

I would recommend that you not dispose() the BitmapData then if you're trying to use that same image again, or you can simply set noCache:true on your ImageLoader. Otherwise, if you have a better idea as to how you'd check if the BitmapData is disposed somehow/somewhere, please let us know. 

Link to post
Share on other sites
var imgLoader:ImageLoader = new ImageLoader("data/img/global_ui/blue/ButtonStd1.jpg", {onComplete : onComplete});
var imgLoader2:ImageLoader = new ImageLoader("data/img/global_ui/blue/ButtonStd1.jpg", {onComplete : onComplete});
imgLoader2.load();
imgLoader.load();
var tempBD:BitmapData = null;
function onComplete(evt:LoaderEvent):void{
if(tempBD == null) tempBD = evt.target.rawContent.bitmapData;
else trace(tempBD == evt.target.rawContent.bitmapData);
}

How about this, suppose the same url should return the same bitmapData but it doesn't. I'm creating a central bitmapData reference for memory efficiency. disposing when unused

There is a work around to check. Can it be checked before dispatchEvent?
Link to post
Share on other sites

I think I read your post 5 times and still can't quite understand what you're asking. Could you rephrase?

Link to post
Share on other sites

Thanks for your effort, I made my work around though. Is a good will to inform about this. I did the above codes as a test, I'm optimizing BitmapData memory reference, from class (library) and url.

 

Your team made below claim :

 

[new in version 1.89:] When you load() an ImageLoader, it will automatically check to see if another ImageLoader exists with a matching url that has already finished loading. If it finds one, it will copy that BitmapData to use in its own Bitmap in order to maximize performance and minimize memory usage. After all, why load the file again if you've already loaded it? (The exception, of course, is when the ImageLoader's noCache is set to true.)

 

 

onComplete will be called twice because loader1 and 2 loaded the same url. Since it is the same url, as from above description on version 1.89, it should return the same BitmapData object memory reference. but as from above test that I've done. I've proven that the memory reference is different. The first test shows the reference is the same when load() called at different time, but when different loaders called at the same time. No offence but greensock framework doesn't check if any other loader is calling the same url. Hence BitmapData object memory reference is different.
 

I know this is very deep level, hardly ppl will go to this extend. I made my work around though, but as a responsible programmer and out of good will, I'll still like to inform you and the development team. 

Link to post
Share on other sites

I may be misunderstanding again, but doesn't the documentation clearly state that it only checks for loaders of the same URL that have already finished? But you're trying to load them simultaneously, right? If you have a workaround that you think is better, please post the revised ImageLoader file so that we can see what you're recommending specifically. Thanks. 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×