AssetLoader is a simple to use library that allows you to load multiple assets at the same time. The aim is to make preloading assets in AS3 as simple as possible, but also give you the functionality and extendibility you need.
- Automatic Type detection.
- Multiple connections, which you can define = faster loading = less waiting = happier users.
- No Events, AS3Signals only.
- No singletons! Construct as many AssetLoaders as you want!
- Data is dispatched with strong types. NO CASTING!
- Endless recursive group loaders within loaders, within loaders, etc.
- Pause/Resume/Destroy capabilities.
- Dynamic parameter system that works with code completion – No guessing!
- Loader parameters smartly inherit from their parent loaders, which means you write less code.
- Real-time loading stats. This provides latency, speed, average and progress of all downloads.
- Consolidated stats, loaders reclusively consolidate loading stats all the way down to the last child.
- Can be configured via XML, straight up or from an external file with one easy call.
- All loader errors are consolidated to one signal. IOError, SecurityError, etc. – you don’t have to worry about it, they all boil down to one place. Which means you can “globally” handle loading errors with one listener/command.
- Interfaces all round.
- Unit tested!
- Works super well with Robotlegs! //what doesn’t
- And some other stuff too!
Understand the concept
I must admit, version 1 of AssetLoader was a bit confusing, but paved a good runway for version 2. Before we continue, please make sure you have read the README on the sources page. Getting on with the concept:
AssetLoader is a cluster of well-oiled classes that focus on making loading assets into Flash as easy as possible. Yes, there are alternatives, but I have yet to see any of the other ones that implement good programming standards and interfaces. Also v2 is fully unit tested to make sure that coming updates don’t break anything.
AssetLoader works on a Child-Parent notation, much like the display layer works. Information is always bubbled upwards to the top level loader, making it easy to “globally” manage errors and completed assets. More on this later…
ILoader – the Work Horse (you and me)
This is the base interface for all loaders, including the AssetLoader itself. An ILoader instance is responsible for loading and managing one asset/file. It wraps & listens to its inner native loader (e.g. URLStream, Sound, NetStream, Loader) and converts the native Events into Signals, updates its Stats module, etc. All these implementations can be constructed and used independently as well; they do not need a parent to function.
IAssetLoader – the Manager (our bosses)
Currently there is only one implementation of the IAssetLoader, namely AssetLoader. At this point only one is needed. IAssetLoader is the one that can contain an infinite amount of child ILoaders, being an ILoader itself; it can also contain instances of itself (IAssetLoaders). IAssetLoader doesn’t wrap or contain any native loaders, it merely manages and oversees its children, but because everything is consolidated it can function as a standard ILoader.