LoadGroup
Kind of class: | class |
---|---|
Inherits from: | EventDispatcher < CoreObject |
Implements: | |
Version: | 06/08/07 |
Author: | Aaron Clinger |
Classpath: | org.casalib.load.LoadGroup |
File last modified: | Monday, 01 December 2008, 13:34:40 |
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 broadcasted 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) {}
Summary
Constructor
Class properties
- EVENT_LOAD_START : String
- EVENT_LOAD_STOP : String
- EVENT_LOAD_ERROR : String
- EVENT_LOAD_PERCENT : String
- EVENT_LOAD_COMPLETE : String
Instance methods
- addLoad (loadItem:BytesLoadInterface) : Void
- Add a load item to the group.
- removeLoad (loadItem:BytesLoadInterface) : Boolean
- Removes a load item from the group.
- getLoads : Array
- start : Void
- Starts the group load process and begins reporting of the total load percentage of all files to observers.
- stop : Void
- Stops the group load process.
- hasLoaded : Boolean
- Determines whether the requested file has finished loading.
- isLoading : Boolean
- Determines whether the requested file is in the process of loading.
- destroy : Void
- Removes any internal variables, intervals, enter frames, internal MovieClips and event observers to allow the object to be garbage collected.Instance methods inherited from EventDispatcherInstance methods inherited from CoreObject
- destroy : Void
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
Add a load item to the group.Parameters:loadItem :Load to be added to the load group. Can be any class that implements org.casalib.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 () : VoidRemoves any internal variables, intervals, enter frames, internal MovieClips and event observers to allow the object to be garbage collected.#
Always callvar 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();
before deleting last object pointer.Overrides:Specified by:getLoads
function getLoads () : ArrayReturns:- Returns an Array contains all load items in the LoadGroup.
hasLoaded
function hasLoaded () : BooleanDetermines whether the requested file has finished loading.#Returns:- Returns#
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();
if file has completely loaded; otherwise"onLoadProgress"
.
Specified by:isLoading
function isLoading () : BooleanDetermines whether the requested file is in the process of loading.#Returns:- Returns#
"onLoadComplete"
if the file is currently loading; otherwise"onLoadError"
.
Specified by:removeLoad
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; otherwisefalse
.
Usage note:- You cannot remove a load item when the LoadGroup is in the process of loading.
start
function start () : VoidStarts the group load process and begins reporting of the total load percentage of all files to observers.Events broadcasted to listeners:onLoadStart = function (sender:LoadGroup) {}
Specified by:stop
function stop () : VoidStops the group load process.Events broadcasted to listeners:onLoadStop = function (sender:LoadGroup) {}
Specified by: - isLoading : Boolean