Posts Tagged ‘loading swfs’

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

    Posted by admin on July 8th, 2008 No Comments