Tuesday, November 27, 2007
AS3 Class: BulkLoader
Tuesday, November 27, 2007
Saw this on the aggre's this morning, and I want to post another link to it, Arthur Debert has released a really cool AS3 class he calls BulkLoader. It's implementation is pretty nice, some sample usage code:
import BulkLoader;Without looking at the support class(es) yet, I assume that it goes through in the order which you added the assets. And you can use keys on retrieval (very nice). Well done, this looks like a really nice direction to take for loading in lots of assets (ie. sites and also larger applications).
var loader:BulkLoader = new BulkLoader("main");
loader.add("bg.jpg");
loader.add("config.xml");
loader.add("soundtrack.mp3");
loader.add("intro.flv");
loader.addEventListener(BulkLoader.PROGRESS, onProgress);
loader.addEventListener(BulkLoader.COMPLETE, onComplete);
loader.start();
function onProgress(evt : BulkProgressEvent):void
{
trace(evt.percentLoaded);
}
function onComplete(evt:Event):void
{
var bgBitmap = loader.getBitmap("bg.jpg");
addChild(bgBitmap);
var video : Video = new Video();
video.attachNetStream(loader.getNetStream("intro.flv"));
parseConfig(loader.getXML("config.xml"));
}
Comments:
There are currently 7 Comments:
-
Zeh said...“It does go through the order you added, but it also allows setting the priority of the loading queue if something needs a higher priority.”



