LoadManager
Kind of class: | class |
---|---|
Inherits from: | EventDispatcher < CoreObject |
Implements: | |
Version: | 06/05/07 |
Author: | Aaron Clinger |
Classpath: | org.casalib.load.LoadManager |
File last modified: | Monday, 01 December 2008, 13:34:40 |
Chains/queues 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 myLoadQueue:LoadManager = LoadManager.getInstance(); this.myLoadQueue.addLoad(mediaLoad); this.myLoadQueue.addLoad(soundLoad); this.myLoadQueue.start();
Events broadcasted to listeners:
onLoadCompleted = function (loadItem:LoadInterface) {}
onLoadError = function (loadItem:LoadInterface) {}
Summary
Class properties
- EVENT_LOAD_COMPLETE : String
- EVENT_LOAD_ERROR : String
Class methods
Instance methods
- addLoad (loadItem:LoadInterface, priority:Boolean) : Void
- Adds item to be loaded in order.
- removeLoad (loadItem:LoadInterface) : Boolean
- Removes item from the load queue.
- removeAllLoads : Void
- Removes all items from the load queue and cancels any currently loading.
- start : Void
- Starts or resumes loading items from the queue.
- stop : Void
- Stops loading items from the queue after the currently loading items complete loading.
- isLoading : Boolean
- Determines whether LoadManager is in the process of loading items from the queue.
- setThreads (threads:Number) : Void
- Defines the number of simultaneous file requests/downloads.
Instance methods inherited from EventDispatcher
Instance methods inherited from CoreObject
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
Instance methods
addLoad
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 queue. Can be any class that inherits from org.casalib.load.base.LoadInterface and dispatches events
"onLoadComplete"
and "onLoadError"
.priority:
[optional] Indicates to add item to beginning of the queue/next file to load
true
, or to add it at the end of the queue false
; defaults to false
.isLoading
function isLoading (
) : Boolean
Determines whether LoadManager is in the process of loading items from the queue.
Returns:
- Returns
true
if the LoadManager is currently actively loading; otherwisefalse
.
removeAllLoads
function removeAllLoads (
) : Void
Removes all items from the load queue and cancels any currently loading.
removeLoad
Removes item from the load queue. If file is currently loading the load is stopped.
Parameters:
loadItem:
Load to be removed from the load queue.
Returns:
- Returns
true
if item was successfully found and removed; otherwisefalse
.
Usage note:
- Load items are automatically removed from LoadManager on load success or error.
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 queue. Pass
0
for unlimited threads.Usage note:
- Class defaults to
1
thread.
start
function start (
) : Void
Starts or resumes loading items from the queue.
Specified by:
stop
function stop (
) : Void
Stops loading items from the queue after the currently loading items complete loading.
Specified by: