>  The only way to reduce traffic is to generate thumbnails on the server, 
> which is more or less what Scene7 does
>

Woah now, I didn't realize they had everyone drinking quite so much of
the Adobe "push the expensive stuff" kool aid :)

You can certainly use AIR to load images and create preview thumbs.
But AIR (and just flash player in general) can be a crazy memory hog
when it comes to loading images, and in AIR you're opening the
possibility of loading huge multi-megabyte images. I'd suggesting
making sure your code to handle resizing is capped at running one or
two at a time (or better yet, figure out the resolution of the images
and change the queue amount to accomodate different numbers of images
based on a target max resoltuion or byte size of the source files).

But in general, load the image, create a bitmapdata of the preview
size you want, then draw it into a much smaller, thumbnail-size
preview (which seems to be what your code does). Then do that over and
over again, being sure to free the large image or bitmap that you
loaded each time (which your code does not seem to do). I was doing
something similar back a while ago and I noticed that AIR wouldn't
properly run the garbage collector when I was dealing with very large
images, but maybe that's been fixed. If not then try manually running
the GC from AIR, or use the localconnection garbage collector hack
(that's what worked for me). And you can also save temporary (or
persisted) thumbnail versions since you're using AIR. So you could do
something like leave a queue of the last 1200 images you generate
thumbnails for in the local app directory.

So be sure to remove the reference to your original _loader object, so
that the full bitmap data can be freed. And I'd suggest using some
kind of queuing system so you don't fire off 100 massive load/resize
operations at the same time. And use the profiler to see if those
large bitmapdata objects are being freed after you load/resize the
images. If not try running the garbage collector using the bult-in AIR
methods or using the localconnection hack. If you only load a one or
two massive images at once and you free the memory in between
processing, you should be ok.

Doug

Reply via email to