LoadGroup
| Kind of class: | class |
|---|---|
| Inherits from: | EventDispatcher < CoreObject |
| Implements: | |
| Version: | 04/09/07 |
| Author: | Aaron Clinger |
| Classpath: | org.casaframework.load.LoadGroup |
| File last modified: | Tuesday, 10 April 2007, 09:46:51 |
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) {} Summary
Constructor
Class properties
Instance properties
Instance properties inherited from EventDispatcher
Instance properties inherited from CoreObject
Instance methods
Instance methods inherited from EventDispatcher
Instance methods inherited from CoreObject
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
#Always call
destroy() before deleting last object pointer.Specified by:
hasLoaded
function hasLoaded (
) : Boolean
Determines whether the requested file has finished loading.
#Returns:
Returns
#true if file has completely loaded; otherwise false.Specified by:
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.Specified by:
removeLoad
function removeLoad (
loadItem:BytesLoadInterface) : Boolean
Removes a load item from the group.
Parameters:
loadItem:
Load to be removed from the load cue.
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) {} Specified by:
stop
function stop (
) : Void
Stops the group load process.
Events broadcast to listeners:
onLoadStop = function (sender:LoadGroup) {} Specified by: