QueueLoaderLite
Updated the code
I’ve stripped down some of the heavier features for an alternate “lite” version for those wishing a bare bones QueueLoader with low file size. QueueLoader will continue to thrive and there are some enhancements to the regular version that will be made shortly.
The lite version is focused exclusively on image and swf asset loading. Application Domain/Loader Context is still there so you can load other items within a swf and have access to its class references in the library. I will add another guide page on the Google page shortly. I’m including all the listening function in the example below just so you can see it in action, but any/all of them can be removed. More examples and documentation on this version to come, but in the meantime… Basic usage:
import com.hydrotik.utils.QueueLoaderLiteEvent;
var qlLoader:QueueLoaderLite = new QueueLoaderLite();
var imageContainer:Sprite = new Sprite();
addChild(imageContainer);
imageContainer.name = “image”;
qlLoader.addItem(“../flashassets/images/slideshow/1.jpg”, imageContainer, {title:“image”});
qlLoader.addEventListener(QueueLoaderLiteEvent.QUEUE_START, onQueueStart, false, 0, true);
qlLoader.addEventListener(QueueLoaderLiteEvent.ITEM_START, onItemStart, false, 0, true);
qlLoader.addEventListener(QueueLoaderLiteEvent.ITEM_PROGRESS, onItemProgress, false, 0, true);
qlLoader.addEventListener(QueueLoaderLiteEvent.ITEM_COMPLETE, onItemComplete, false, 0, true);
qlLoader.addEventListener(QueueLoaderLiteEvent.ITEM_ERROR, onItemError, false, 0, true);
qlLoader.addEventListener(QueueLoaderLiteEvent.QUEUE_PROGRESS, onQueueProgress, false, 0, true);
qlLoader.addEventListener(QueueLoaderLiteEvent.QUEUE_COMPLETE, onQueueComplete, false, 0, true);
qlLoader.execute();
function onQueueStart(event : QueueLoaderLiteEvent):void {
trace(“** “+event.type);
}
function onItemStart(event : QueueLoaderLiteEvent):void {
trace(“>> “+event.type, “item title: “+event.title);
}
function onItemProgress(event : QueueLoaderLiteEvent):void {
trace(“\t>> “+event.type+“: “+[” percentage: “+event.percentage]);
}
function onItemComplete(event : QueueLoaderLiteEvent):void {
trace(“>> name: “+event.title + ” event:” + event.type+” - “+[“target: “+event.targ, “w: “+event.width, “h: “+event.height]+“\n“);
}
function onItemError(event : QueueLoaderLiteEvent):void {
trace(“>> name: “+event.title + ” event:” + event);
}
function onQueueProgress(event : QueueLoaderLiteEvent):void {
trace(“\t>> “+event.type+“: “+[” queuepercentage: “+event.queuepercentage]);
}
function onQueueComplete(event : QueueLoaderLiteEvent):void {
trace(“** “ + event.type);
}
And for instantiating library assets in an external swf library:
import com.hydrotik.utils.QueueLoaderEventLite;
var addedDefinitions:LoaderContext = new LoaderContext();
addedDefinitions.applicationDomain = ApplicationDomain.currentDomain;
var qlLoader:QueueLoaderLite = new QueueLoaderLite(false, addedDefinitions);
var soundSWF = new MovieClip();
soundSWF.name = “externalSounds”;
addChild(soundSWF);
var soundChannel:SoundChannel = new SoundChannel();
qlLoader.addItem(prefix(“”) + “flashassets/swf/externalsounds.swf”, soundSWF});
qlLoader.addEventListener(QueueLoaderLiteEvent.QUEUE_COMPLETE, onQueueComplete,false, 0, true);
qlLoader.execute();
function onQueueComplete(event:QueueLoaderLiteEvent):void {
trace(“** “+event.type);
var Loop1Reference:Class = getDefinitionByName(“Loop1″) as Class;
var loop1:Sound = new Loop1Reference();
soundChannel = loop1.play();
}
QueueLoaderLite Source
Tuesday, March 11th, 2008