Basic Image Loader in AS3

Basic wee loader which loads an image, then is put inside a container movieclip.

// image loader
var imageLoader:Loader = new Loader();
imageLoader.load(new URLRequest("thumbnails/example_thumb.jpg"));

var myImage:MovieClip = new MovieClip();
myImage.addChild(imageLoader);


addChild(myImage);

If you want something to happen when it’s loaded (like load the next one etc, slap a listener on the contentLoaderInfo beneath the loader. Each loader has contentLoaderInfo and that can give you heaps of variables about the loader – bytes loaded etc, see the livedoc: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/LoaderInfo.html

imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadedHandler);
Tech Reference:

Leave a Reply

Your email address will not be published. Required fields are marked *

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑