find the files here.
Since Flash8 came out, i’ve moved away from the old multi-keyframed movieclip used for sprites in my games. I’ve been playing around with loading images into a movieclip, copying the pixels into a BitmapData instance, then discarding the mc and passing that data onto whoever wants it. After trying a couple different ways on how to manage this process, i was thumbing through Killer Game Programming by Andrew Davison and thought his ImagesLoader class (written in java) was pretty damn cool and decided i wanted a Flash adaptation of it.
Seeing as Flash doesn’t have a BufferedImage, I drummed up a little implementation of buffering images offscreen and here it is.
The prominant class file that the different buffers (Single, Strip, Multi) use is the ImageLoader – which does pretty much what i said in the first sentence.
The different buffers know what to do with the bitmapdata passed from ImageLoader, but perhaps more importantly they have a queue system set up so that you can hit these Singletons with numerous filepaths to images and the loading of one won’t get overwritten by the loading of another.
The ImageLoader and buffers can be used seperately from the ImagesLoader, but the ImagesLoader class is there if you want a sort of buffered image manager. It holds basically an image map from which another class can grab the bitmap data of anything loaded. As well, taking a cue from Andrew Davison’s ImageLoader.java, ImagesLoader can read a text file that lists all the images you want loaded and buffered in your app, choosing buffers dependant on a preceding signifier (single, strip, group, number).
I find it helpful and it probably could use some optimization, but hopefully you can get something out of it… And please don’t forget to call ImagesLoader.dispose() when you’re done with it.
In the zip are the files, a sample FLA, some images and an image.txt file. I realized that some of the images don’t really illustrate the point because they’re simple and you’d probably use the drawing API instead, but you get the idea of how the ImagesLoader works.



Nice. I’m wondering though why you’re not using MovieClipLoader. Also, it would probably be a bit faster if your ImageQueue would load more than one image at a time, since a client can have a couple of connections open at the same time and ping time is usually independant of whether you have 1 or several connections open.
Thanks Patrick.
you’re right, i should be using MovieClipLoader… just was lazy i guess
Nice suggestion on the queue. Every queue system i’ve created always had a ‘one in, one out’ turnstile idea. Never really thought about sending a couple through.
thanks.