Loader vs. URLLoader in ActionScript 3

This short tutorial is written in response to a question on the Flash and Math Discussion Forum: "How can you load a random image from a list of images specified in an external XML file?" The question presents an opportunity to show a simple example that illustrates the difference between Loader and URLLoader classes. According to Flash documentation, the former class is for swf and image formats (gif, jpg, and png) while the latter is for text and binary data. Hence, we will use URLLoader to open an XML file that contains a list of names (URLs, technically) of image file, and then use a Loader to load an image from the list.

Refresh your browser window to see a randomly chosen image from a list of four images (by Jess Ensley) whose names are specified in an external xml file

The first page of the tutorial presents commented code to accomplish the effect shown above. The second page shows how to randomize the list of images for a different effect.

Download

Download the file randompic.zip to get all source files and sample images for this tutorial.

Back to Basic Tutorials              Back to Flash and Math Home

The site www.flashandmath.com is maintained by Doug Ensley (doug@flashandmath.com) and Barbara Kaskosz (barbara@flashandmath.com).
It has been developed with partial funding from the National Science Foundation and the Mathematical Association of America.