[SOLVED] How to display many large images?


(Ecen Cronzeton) #1

I have a flash application for navigating through a relatively large amount if medium sized images (usually around 800x600). To not have to write one Embed statement for each image I generate a few spritesheets using my images which usually gives me two large spritesheets (around 4000x4000, larger ones causes memory issues). I then embed these on startup.

I have now however run into the problem that I can’t embed more than two of these spritesheets, or the build fails. I’m assuming this has to do with the size of each spritesheet but I do not know as no error message is shown.

So, is there a better, and functional, way to display lots of relatively large images? I only need to display one at a time, but I need to be able to switch between them relatively fast.


(rostok) #2

You can either load images dynamically, here’s the quick snippet you will have to adjust yourself:

    loader = new Loader();
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imgComplete);
    loader.load(new URLRequest(prefix + imageURL));
...
    private function imgComplete(e:Event):void {
            loader.removeEventListener(Event.COMPLETE, imgComplete);
            dictionary[filename] = Bitmap(e.target.content).bitmapData
    }

Alternatively you can embed all those images as binary data - for example as ziped archive and later decode them. Unfortunately you will have to use 3rd party libraries to access zips and do JPEG decoding.

Each of those two methods will surely reduce compilation times. Also if you are using Flashdevelop you should maximize memory usage in jvm.config.

Finally I recommend using @jacobalbano’s FlakIT asset library


(Jacob Albano) #3

Worth noting that FLAKit will only solve this problem while in debug mode. If you want to release as a standalone SWF you’ll still need to embed them.

However, it will indeed help with the issue of having to write all those embed statements. FLAKit can generate embed statements for all your assets. Check out the topic to see if it suits your needs.


(rostok) #4

What about loading files from webserver?


(Ecen Cronzeton) #5

Thank you for the multi-useful help! While everything you wrote is indeed helpful, I noticed that just increasing the memory usage in jvm.config solved my initial problem with the build failing. Because of the nature of my project, and because it is the far easiest, I will thus keep loading images as I have previously. I will however be looking into the other methods for future projects.