AS2 SequentialLoader Class:
A long while back, i needed to write a class that could be used to load a series of swfs or images in sequence, and monitor the progress of each item in the sequence or the sequence as a whole. SequentialLoader is what i came up with, and it has come in handy every once and a while since. Essentially, the instance is created by passing in an array of assets (images or swfs) and an array of holder MCs to load the assets into. Once instantiated, startLoad can be called on the SequentialLoader instance, and the instance will broadcast events to anything that has registered as a listener.
Now that i'm thinking about making it publicly available, i've decided to go back and clean it up a bit. It should be done in a day or two, and when it's ready, i'll post the code, and an example for download. Check back for updates to this post...
Here's a really simple example of how the class is used:
-
import com.staticmethods.loader.SequentialLoader;
-
-
var assets:Array = new Array("one.jpg", "two.jpg", "three.jpg");
-
var holders:Array = new Array(holder1_mc, holder2_mc, holder3_mc);
-
-
var sl:SequentialLoader = new SequentialLoader(assets, holders);
-
sl.addEventListener(SequentialLoader.EVENT_SEQUENCE_COMPLETE, this.handleSequenceComplete);
-
sl.start();
-
-
function handleSequenceComplete($eventObj:Object):Void
-
{
-
trace("Everything is loaded!");
-
}