LoadGroup

Kind of class:class
Inherits from:EventDispatcher < CoreObject
Implements:
Version:06/08/07
Author:Aaron Clinger
Classpath:org.casaframework.load.LoadGroup
File last modified:Sunday, 19 August 2007, 13:43:26
Allows multiple loads to be treated as one larger load item.
Example:
var xmlLoad:XmlLoad = new XmlLoad("test.xml");
var imageLoad:MediaLoad = new MediaLoad(this.loadZone_mc, "test.jpg");

var myLoadGroup = new LoadGroup();
this.myLoadGroup.addLoad(this.xmlLoad);
this.myLoadGroup.addLoad(this.imageLoad);
this.myLoadGroup.addEventObserver(this, LoadGroup.EVENT_LOAD_PERCENT, "onGroupLoadPercent");
this.myLoadGroup.addEventObserver(this, LoadGroup.EVENT_LOAD_ERROR, "onGroupLoadError");

function onGroupLoadPercent(sender:LoadGroup, progress:Percent):Void {
    trace("My group is " + progress.getPercentage() + "% loaded.");
}

function onGroupLoadError(sender:LoadGroup, failedLoad:BytesLoadInterface):Void {
    this.myLoadGroup.removeLoad(failedLoad);
    this.myLoadGroup.start();
}

this.myLoadGroup.start();
Events broadcast to listeners:
onLoadStart = function (sender:LoadGroup) {}
onLoadStop = function (sender:LoadGroup) {}
onLoadComplete = function (sender:LoadGroup) {}
onLoadPercent = function (sender:LoadGroup, progress:Percent) {}
onLoadError = function (sender:LoadGroup, failedLoad:BytesLoadInterface) {}

Constructor

LoadGroup

function LoadGroup ()
Creates a new LoadGroup object.

Class properties

EVENT_LOAD_COMPLETE

static EVENT_LOAD_COMPLETE:String = 'onLoadComplete'(read,write)

EVENT_LOAD_ERROR

static EVENT_LOAD_ERROR:String = 'onLoadError'(read,write)

EVENT_LOAD_PERCENT

static EVENT_LOAD_PERCENT:String = 'onLoadPercent'(read,write)

EVENT_LOAD_START

static EVENT_LOAD_START:String = 'onLoadStart'(read,write)

EVENT_LOAD_STOP

static EVENT_LOAD_STOP:String = 'onLoadStop'(read,write)

Instance methods

addLoad

function addLoad (loadItem:BytesLoadInterface, percentOfGroup:Percent) : Void
Add a load item to the group.
Parameters:
loadItem :
Load to be added to the load group. Can be any class that implements org.casaframework.load.base.BytesLoadInterface and dispatches events "onLoadProgress", "onLoadComplete" and "onLoadError".
percentOfGroup:
[optional] Defines the percentage of the total group the size of the load item represents; defaults to equal increments.

destroy

function destroy () : Void
Removes any internal variables, intervals, enter frames, internal MovieClips and event observers to allow the object to be garbage collected.

Always call destroy() before deleting last object pointer.
#

getLoads

function getLoads () : Array
Returns:
Returns an Array contains all load items in the LoadGroup.

hasLoaded

function hasLoaded () : Boolean
Determines whether the requested file has finished loading.
#
Returns:
Returns true if file has completely loaded; otherwise false.
#

isLoading

function isLoading () : Boolean
Determines whether the requested file is in the process of loading.
#
Returns:
Returns true if the file is currently loading; otherwise false.
#

removeLoad

function removeLoad (loadItem:BytesLoadInterface) : Boolean
Removes a load item from the group.
Parameters:
loadItem:
Load to be removed from the load group.
Returns:
Returns true if item was successfully found and removed; otherwise false.
Usage note:
You cannot remove a load item when the LoadGroup is in the process of loading.

start

function start () : Void
Starts the group load process and begins reporting of the total load percentage of all files to observers.
Events broadcast to listeners:
onLoadStart = function (sender:LoadGroup) {}

stop

function stop () : Void
Stops the group load process.
Events broadcast to listeners:
onLoadStop = function (sender:LoadGroup) {}