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
March 22nd, 2008 at 11:07 am
hi Donovan,
first of all thanks for the work you are putting here, great classes. I found your page when searching for a class that would help me out dealing with loading images. And seams i’ve found the place. I’m having some difficulties when using the provided code, I’m working in timeline, so just copied the code and it throws some errors:
1067: Implicit coercion of a value of type flash.display:Sprite to an unrelated type Class.
March 22nd, 2008 at 1:18 pm
Thanks. I forgot to add the string variable for the image path. I updated the post. Where it said pt, you would add a sting path to your asset.
March 22nd, 2008 at 3:07 pm
so i’ve write a comment with too much charaters :p
… just realise now. any ideias how can I write some more lines?!… cause still have some doubts I’d love to share with you
thanks
March 23rd, 2008 at 6:06 pm
Updated the example.
April 30th, 2008 at 4:33 pm
Hi…
Quick question…how would I get the “queuepercentage” value from the AS2 version of QueueLoader? It has the event onQueueProgress, but I don’t see the queuepercentage property.
Thanks for moving this to AS3. I use it all the time, but now need to go back to AS2 and never ran into this.
April 30th, 2008 at 5:09 pm
I didn’t do the AS2 version, but as far as I know it doesn’t support an overall monitoring percentage.
May 1st, 2008 at 2:18 pm
I have a little problem.
I’m loading a group of images and want to position them on the go, but if I try to get domensions of an mc:
function onItemComplete(event:QueueLoaderLiteEvent):void {
trace(img.width);
}
The function returns the dimensions only when the last onItemComplete is fired and returns 0 for every item before.
How can I position items while loading them ?
May 1st, 2008 at 2:45 pm
event.width and event.height will access the properties when the item has completed loading.
May 1st, 2008 at 6:44 pm
Thanks man, I’ve already done it by getting dimensions of a previous image in onItemStart but this is even easier.
I’ve got another problem now,
when I test the movie in Flash all event functions are fired but if I either simulate download or open the file in a browser only the first ‘onItemStart’ and ‘onItemProgress’ are fired. The first onItemComplete and the other functions (for next items) are never called although files are loaded one after another.
How to solve this ? What could I do wrongly ?
June 27th, 2008 at 6:41 am
hi .. first of all .. thanks for this great piece of code!
i have a question .. is there a way to pause the queue and then resume it? if yes, then i would appreciate a for some help how to do it.
thanks again
bests
alan
June 27th, 2008 at 1:24 pm
Not with QueueLoaderLite, but this should work with QueueLoader. download the latest from the SVN
http://code.google.com/p/queueloader-as3/
I’ll try and upload the file here as well on the google code download site.. was giving me problems when I tried to update last time.
July 8th, 2008 at 3:48 pm
great resource. I needed this for an AS2 project and made an AS2 version available on my blog:
http://fboyle.com/blog/?p=17
not as feature rich but it may be useful none-the-less:)
-Individual monitoring
-Overall queue monitoring
-Image loading
-SWF loading
-MP3 loading
July 8th, 2008 at 5:48 pm
QueueLoader for AS3 was actually based on a class that was already written for AS2. Didn’t have as many features, but might have saved you a little trouble:)
http://www.betriebsraum.de/blog/downloads/
July 9th, 2008 at 1:34 am
…but then I wouldn’t have learnt anything