LoadManager

Kind of class:class
Inherits from:EventDispatcher < CoreObject
Implements:
Version:04/04/07
Author:Aaron Clinger
Classpath:org.casaframework.load.LoadManager
File last modified:Wednesday, 04 April 2007, 16:36:25
Chains/cues load requests together in the order added. To be used when loading multiple items of same or different type.
Example:
var mediaLoad:MediaLoad = new MediaLoad(this.loadZone_mc, "test.jpg");
var soundLoad:SoundLoad = new SoundLoad(this.soundContainer_mc, "audio.mp3");

var myLoadCue:LoadManager = LoadManager.getInstance();
this.myLoadCue.addLoad(mediaLoad);
this.myLoadCue.addLoad(soundLoad);
this.myLoadCue.start();
Events broadcast to listeners:
onLoadCompleted = function (loadItem:LoadInterface) {}
onLoadError = function (loadItem:LoadInterface) {}

Class properties

EVENT_LOAD_COMPLETE

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

EVENT_LOAD_ERROR

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

Class methods

getInstance

static function getInstance (
Returns:
LoadManager instance.

Instance methods

addLoad

function addLoad (
loadItem:LoadInterface, priority:Boolean) : Void
Adds item to be loaded in order. Can also be used to change a file from/to a priority load.
Parameters:
loadItem:
Load to be added to the load cue. Can be any class that inherits from org.casaframework.load.base.LoadInterface and dispatches events "onLoadComplete" and "onLoadError".
priority:
[optional] Indicates to add item to beginning of the cue/next file to load true, or to add it at the end of the cue false; defaults to false.

removeAllLoads

function removeAllLoads (
) : Void
Removes all items from the load cue and cancels any currently loading.

removeLoad

function removeLoad (
loadItem:LoadInterface) : Boolean
Removes item from the load cue. If file is currently loading the load is stopped.
Parameters:
loadItem:
Load to be removed from the load cue.
Returns:
Returns true if item was successfully found and removed; otherwise false.

setThreads

function setThreads (
threads:Number) : Void
Defines the number of simultaneous file requests/downloads.
Parameters:
theads:
The number of threads the class will theoretically use, though most browsers cap the amount of threads and hold the other requests in a cue. Pass 0 for unlimited threads.
Usage note:
Class defaults to 1 thread.

start

function start (
) : Void
Starts or resumes loading items from the cue.

stop

function stop (
) : Void
Stops loading items from the cue after the currently loading items complete loading.