Jump to content
GreenSock

tsangwailam

LoaderMax: Cache System

Recommended Posts

Hi All,

 

LoaderMax seem a great loader. I have a suggestion on the feature.

 

I suggest to add a cache system in the loader. Since i have some project will load a large amount of image ( may repeat sometime). I have build a cache system in my current project framework.

 

The system will cached the image after load. The loader can get loaded image without reloading the image once. After a period of ideal time, the loader will do a gc and clean the cache. Even more, i have create a small thumbnail on the image and the loader can get the thumbnail of a loaded image before reloading.

 

I don't know it is make sense to implement the cache system in the LoaderMax. Since i don't think every user need to load a large amount of images.

 

William

Digicrafts

Link to comment
Share on other sites

Help me understand how the existing features of LoaderMax don't give you what you need. When you load an image, it retains it unless you dispose() the loader. So you can getContent() or getLoader() any time based on the name or URL. Isn't that pretty much exactly like a cache?

 

I don't want to build in thumbnail generation because it would eat up too much kb and I don't think a large portion of the user base would use it (not enough to justify the kb expense at least). I appreciate the suggestion, though.

Link to comment
Share on other sites

There is one case where I believe Grant Skinner made an image loader specifically for use in Flex lists since they flicker when using standard image loaders when the item renderers are reused. So when a cell with an image goes off the top or bottom and comes back in you would see that flicker as the item renderer pulled in that image again presumably from the browser cache. The workaround was to cache the bitmap data and check the name being requested. If it was already loaded it would pull that bitmap data directly and override Flex's update so you didn't see the flicker. This is all from memory from a very long time ago so I'm sure there are bits that are not correct. :) Flex 2 I think even. Since the data is ever present though in this case via getContent/Loader() that could mitigate it. To be honest I don't know if Flex3/4 has this issue now.

Link to comment
Share on other sites

  • 1 month later...

Hi!

 

Just throwing in my request for an internal caching system for images. I have one I've used in AS 2.0 for a long time and it has always been a great help. When an image is loaded, it is saved as BitmapData. Then the image is pulled from the BitmapData for all subsequent load requests. Originally I only used it for projects with large amounts of images, but I finally just integrated it with the loading system using the URL as the identifier and have never looked back.

 

Rather than rewriting my loading system for AS 3.0 (I know I've been slack) I was looking to use yours. :) I love your Tweening engine and I'm sure LoaderMax is just as good, but for me, it just needs that one last feature.

 

Cheers,

Bill

Link to comment
Share on other sites

Did you see my previous post? I'm confused - please explain how the existing features of LoaderMax don't give you what you need. When you load an image, it retains it unless you unload() it. So you can getContent() or getLoader() any time based on the name or URL. Isn't that pretty much exactly like a cache? And if you load() a loader that has already completed, it just uses what it has (doesn't force a reload unless you set the "flush" parameter to true). What's missing?

Link to comment
Share on other sites

Hi,

 

Sorry, I guess I was a bit confused when you said it retained it. I thought you meant it retained the loader information, (so you didn't have to recreate the loader) not that it retained the actual image data. If you already retain the image data inside the SWF then it certainly sounds like a cache to me! :) Very cool! If I may ask, how do you retain the image data and does that have any significant negative effects on memory usage when a large amount of images are "cached"?

 

Thanks for the quick response! You are doing some excellent work!

 

Cheers,

Bill

Link to comment
Share on other sites

If I may ask, how do you retain the image data and does that have any significant negative effects on memory usage when a large amount of images are "cached"?

 

It retains the image simply as an internal reference. As far as memory goes, yes, anything you load does indeed need to be stored in memory (albeit in a compressed format until it's actually in the display list or you perform BitmapData operations on it). You're welcome to unload() content if you prefer and then load() it again when you need it. That'd obviously slow things down a bit, so you need to weigh the cost/benefit ratio based on the number and size of images you're loading and how fast your app needs to respond, etc.

 

Have fun! :)

Link to comment
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.
×