Game Development Reference
In-Depth Information
Note that the Loader has a specific LoaderContext object created
for it, which directs it to place the Loader
s class definitions in a
common ApplicationDomain. Each Loader also has a progress
event linked to it, which we will discuss next.
protected function assetLoadProgress(e:ProgressEvent):void {
var baseCompletion:Number = 100 * (_assets.length-1)/
var currentProgress:Number = (100/_assetQueue.length) *
var bytesLoaded:int = Math.round(baseCompletion +
var pe:ProgressEvent = new ProgressEvent(ProgressEvent.
PROGRESS, false, false, bytesLoaded, 100);
To create an accurate percentage of how much of the level assets
have loaded (without knowing the file size of each one), we have to
create a custom ProgressEvent. It takes into account the number of
items to load and the individual progress of each asset to create an
event with somewhere between 0 and 100 bytes loaded, which repre-
sents the percent loaded. Naturally, if the asset files are dramatically
different in size, this means of measuring completion will seem a little
erratic, but it will be as accurate as we can get without loading all of
the files at once (which can choke on some Internet connections).
protected function assetsLoaded(e:Event):void {
if (_assets.length
_assetQueue.length) {
var pe:PlatformerEvent = new PlatformerEvent(Platformer
protected function assetLoadError(e:IOErrorEvent):void {
trace( " PlatformEngine: Error Loading Asset: " ,_assetQueue
protected function getAssetClass(assetName:String):Class {
if (_assetDomain.hasDefinition(assetName)) {
return _assetDomain.getDefinition(assetName) as
Search Nedrilad ::

Custom Search