Bespoke App development for the Web and Devices

Queueloader class for AS2


07.08.08 Posted in Actionscript by admin

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 + " %");
    }

    Post to Twitter



    Leave a Reply

    You must be logged in to post a comment.

    Twitter Updates
    Mobile site
    QR Code - scan to visit our mobile site