Bulkloader example: loading photos with the LazyXMLLoader class

Creating the Flash and Actionscript files

Create a flash file and name it whatever you want. In the Document Class, write LazyXMLPhotoLoader:

So, unlike using the regular BulkLoader Class, the LazyXMLLoader assumes that you are loading multiple files (otherwise why use XML?) and so has a special function that creates a unique id for each item you load based on the file name:

BulkLoader.getUniqueName()

Naturally, you probably shouldn’t use the huge file names like in the example I have provided…but that’s something else entirely.

Once the LazyXMLLoader is ready to fire events for INDIVIDUAL items, it fires a LAZY_COMPLETE event, which you can set your project to listen for:

_bulkLoader.addEventListener(LazyBulkLoader.LAZY_COMPLETE, onLazyComplete);

You can then use a foreach loop to loop through each item being loaded and set up individual event listeners:

public function onLazyComplete(evt : Event):void
		{
			for each (var item:LoadingItem in _bulkLoader.items) {
				item.addEventListener("complete", onPhotoLoaded);
			}
		}

The rest of the code pretty much works like my previous tutorial.

Here are some links for reference:

http://code.google.com/p/bulk-loader/source/browse/trunk/src/br/com/stimuli/loading/lazyloaders/LazyXMLLoader.as
http://code.google.com/p/bulk-loader/wiki/BulkLoaderInExternalFiles

http://code.google.com/p/bulk-loader/source/browse/trunk/tests/src/br/com/stimuli/loading/tests/LazyXMLLoaderTest.as