Queueloader class for AS2

I've written a helper class for loading and monitoring resources which is based upon an AS3 library called Queueloader located at Google Code.  My version is written in AS2 and has the following features:

  • Individual monitoring
  • Overall queue monitoring
  • Image loading
  • SWF loading
  • MP3 loading
  • I've tried to keep the syntax as close to the AS3 version as I could:

     
    import com.fboyle.load.QueueLoader;
    import com.fboyle.load.QueueLoaderEvent; 
     
    var queue:QueueLoader = new QueueLoader();   
     
    var infoOb:Object = new Object();
    infoOb.id = "123456";   
     
    queue.addItemAt("sample1.swf", _root.tmp, infoOb);
    queue.addItemAt("sample2.swf", _root.tmp2, null);   
     
    queue.execute();   
     
    queue.addEventListener(QueueLoaderEvent.ITEM_PROGRESS, itemProgress);
    queue.addEventListener(QueueLoaderEvent.ITEM_COMPLETE, itemComplete);
    queue.addEventListener(QueueLoaderEvent.QUEUE_COMPLETE, queueComplete);   
     
    function itemProgress(ev:Object):Void {
         trace(ev.file + ": " + ev.percent + "%");
    }   
     
    function itemComplete(ev:Object):Void {
         trace(ev.file+ " is loaded! (id - "+ ev.id + ")");
    }   
     
    function queueComplete(ev:Object):Void {
         trace("queue is complete----------");
    }

    The classes files are available here: com.fboyle.load.*

    Update:

    After reading some comments over on Actionscriptclasses.com I've added QueueLoaderEvent.QUEUE_PROGRESS so that the entire queue progress can be monitored with the aid of a percent property:

     
    queue.addEventListener(QueueLoaderEvent.QUEUE_PROGRESS, queueProgress);
     
    function queueProgress(ev:Object):Void
    {
    	trace("Overall progress: " + ev.percent + " %");
    }

    Tags: , ,

    This entry was posted on Tuesday, July 8th, 2008 at 11:56 pm and is filed under Actionscript. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

     

    Leave a Reply

    You must be logged in to post a comment.