| Package | ch.capi.net |
| Class | public class MassLoader |
| Inheritance | MassLoader flash.events.EventDispatcher |
| Implements | IMassLoader |
| Subclasses | PriorityMassLoader |
IMassLoader object. The files will be loaded
into the order of they have been added into the loading queue. In order to create some ILoadableFile,
use the LoadableFileFactory class. If you want to specify some priority
to the loaded files, check the PriorityMassLoader class.
It is important to note that the files won't be stored anymore after they have been completely loaded. You should
have anoter reference to the created ILoadManager objects to access them and prevent that the Garbage Collector
destroy them.
var cl:CompositeMassLoader = new CompositeMassLoader();
cl.addFile("myFile.txt");
cl.addFile("myAnim.swf");
var ml:IMassLoader = cl.massLoader;
var eventFile:Function = function(evt:MassLoadEvent):void
{
var src:ILoadableFile = (evt.file as ILoadableFile);
trace(evt.type+" => "+src.urlRequest.url);
}
ml.addEventListener(MassLoadEvent.FILE_OPEN, eventFile);
ml.addEventListener(MassLoadEvent.FILE_CLOSE, eventFile);
var onMassLoadComplete:Function = function(evt:Event):void
{
trace("massload complete");
}
ml.addEventListener(Event.COMPLETE, onMassLoadComplete);
cl.start();
//ml.start() also works
var lf:LoadableFileFactory = new LoadableFileFactory();
var file1:ILoadableFile = lf.create("myFile.txt");
var file2:ILoadableFile = lf.create("myAnim.swf");
var ml:MassLoader = new MassLoader();
ml.addFile(file1);
ml.addFile(file2);
var eventFile:Function = function(evt:MassLoadEvent):void
{
var src:ILoadableFile = (evt.file as ILoadableFile);
trace(evt.type+" => "+src.urlRequest.url);
}
ml.addEventListener(MassLoadEvent.FILE_OPEN, eventFile);
ml.addEventListener(MassLoadEvent.FILE_CLOSE, eventFile);
var onMassLoadComplete:Function = function(evt:Event):void
{
trace("massload complete");
}
ml.addEventListener(Event.COMPLETE, onMassLoadComplete);
ml.start();
See also
| Property | Defined by | ||
|---|---|---|---|
| alwaysDispatchProgressEvent : Boolean = false
Defines if the progress event should be dispatched each time or
only when all the number of specified parallel files are being
loaded.
| MassLoader | ||
| bytesLoaded : uint [read-only]
Defines the bytes that have been loaded.
| MassLoader | ||
| bytesTotal : uint [read-only]
Defines the total bytes to load.
| MassLoader | ||
| closeEvent : Event [read-only]
Defines the event that happend to close the file (Event.CLOSE, Event.COMPLETE, ...).
| MassLoader | ||
| loadInfo : ILoadInfo
[read-only]
Defines the
ILoadInfo object linked to the IMassLoader. | MassLoader | ||
| loadPolicy : ILoadPolicy
Defines the
ILoadPolicy to use. | MassLoader | ||
| nextFileToLoad : ILoadManager
[read-only]
Defines the next file that will be extracted from the queue to be loaded.
| MassLoader | ||
| numFilesLoading : uint [read-only]
Defines the number of files being currently loaded.
| MassLoader | ||
| parallelFiles : uint
Defines the number of files that will be loaded simultaneously.
| MassLoader | ||
| stateIdle : Boolean [read-only]
Defines if the
MassLoader is idle. | MassLoader | ||
| stateLoading : Boolean [read-only]
Defines if the
MassLoader is loading. | MassLoader | ||
| useCache : Boolean
Defines if the
MassLoader can use the cache or not. | MassLoader | ||
| Property | Defined by | ||
|---|---|---|---|
| files : IList
[read-only]
Defines all the files that must be loaded.
| MassLoader | ||
| filesLoading : IList
[read-only]
Defines the files that are currently being loaded.
| MassLoader | ||
| filesQueue : IDataStructure
Defines the data structure to use for the file enqueuing.
| MassLoader | ||
| Method | Defined by | ||
|---|---|---|---|
|
MassLoader(parallelFiles:uint = 0, useCache:Boolean = true, loadPolicy:ILoadPolicy = null)
Creates a new
MassLoader object. | MassLoader | ||
|
addFile(file:ILoadManager):void
Add a file to the loading queue.
| MassLoader | ||
|
clear():void
Empty the loading queue.
| MassLoader | ||
|
getFileCount():uint
Get the number of files to be loaded.
| MassLoader | ||
|
getFiles():Array
Get the files that will be loaded.
| MassLoader | ||
|
hasFile(file:ILoadManager):Boolean
Retrieves if a file is contained into the loading queue.
| MassLoader | ||
|
removeFile(file:ILoadManager):void
Removes a file from the loading queue.
| MassLoader | ||
|
start():void
Starts downloading data from the specified
ILoadableFile objects. | MassLoader | ||
|
stop():void
Stops the load operation in progress.
| MassLoader | ||
|
toString():String
Lists all the files contained into this
MassLoader into a String. | MassLoader | ||
| Method | Defined by | ||
|---|---|---|---|
|
isComplete():Boolean
Defines if the massive loading is complete.
| MassLoader | ||
|
loadFile(file:ILoadManager):Boolean
Start the loading of a file.
| MassLoader | ||
|
Start the loading of the next file.
| MassLoader | ||
|
onClose(evt:Event):void
Event.CLOSE listener. | MassLoader | ||
|
onComplete(evt:Event):void
Event.COMPLETE listener. | MassLoader | ||
|
onIOError(evt:IOErrorEvent):void
IOErrorEvent.IO_ERROR listener. | MassLoader | ||
|
onOpen(evt:Event):void
Event.OPEN listener. | MassLoader | ||
|
onProgress(evt:ProgressEvent):void
ProgressEvent.PROGRESS listener. | MassLoader | ||
|
onSecurityError(evt:SecurityErrorEvent):void
SecurityError.SECURITY_ERROR listener. | MassLoader | ||
|
Processes the loading policy on the currently closed file.
| MassLoader | ||
|
registerTo(file:ILoadManager):void
Register the
MassLoader to the specified ILoadManager
object's events. | MassLoader | ||
|
startLoading():void
Start the loading of the files.
| MassLoader | ||
|
unregisterFrom(file:ILoadManager):void
Unregister the
MassLoader from the specified ILoadManager
object's events. | MassLoader | ||
|
updateBytes():void
Updates the
bytesLoaded and bytesTotal values. | MassLoader | ||
| Event | Summary | Defined by | ||
|---|---|---|---|---|
| Dispatched when the download operation stops. | MassLoader | |||
| Dispatched after all the data is received. | MassLoader | |||
Dispatched when the loading of a ILoadManager is closed (eg when the loading is complete or
an error has occured). | MassLoader | |||
Dispatched when the MassLoader starts the loading of a file. | MassLoader | |||
Dispatched when the download operation commences following a call to the MassLoader.load()
method. | MassLoader | |||
| Dispatched when data is received as the download operation progresses. | MassLoader | |||
| alwaysDispatchProgressEvent | property |
public var alwaysDispatchProgressEvent:Boolean = falseDefines if the progress event should be dispatched each time or only when all the number of specified parallel files are being loaded.
| bytesLoaded | property |
bytesLoaded:uint [read-only]Defines the bytes that have been loaded.
Implementation public function get bytesLoaded():uint
| bytesTotal | property |
bytesTotal:uint [read-only]Defines the total bytes to load.
Implementation public function get bytesTotal():uint
| closeEvent | property |
closeEvent:Event [read-only]Defines the event that happend to close the file (Event.CLOSE, Event.COMPLETE, ...).
Implementation public function get closeEvent():Event
| files | property |
files:IList [read-only]Defines all the files that must be loaded.
Note that a file can be in the files list and not in the queue list. It means
that the file is currently being loaded. After being loaded, the file is totally
removed from the MassLoader.
protected function get files():IList
| filesLoading | property |
filesLoading:IList [read-only]
Defines the files that are currently being loaded. This list conaints only the files
that dispatches the Event.OPEN event.
protected function get filesLoading():IList
See also
| filesQueue | property |
filesQueue:IDataStructure [read-write]
Defines the data structure to use for the file enqueuing. By default, a
QueueList is used. The MassLoader will use this
IDataStructure to retrieves the next file to load. All the objects
contained into the list must implement the ILoadManager interface.
protected function get filesQueue():IDataStructure
protected function set filesQueue(value:IDataStructure):void
See also
| loadInfo | property |
loadInfo:ILoadInfo [read-only]
Defines the ILoadInfo object linked to the IMassLoader.
public function get loadInfo():ILoadInfo
| loadPolicy | property |
loadPolicy:ILoadPolicy [read-write]
Defines the ILoadPolicy to use. If the specified ILoadPolicy returns a
ILoadManager, then the loaded bytes of the current file are decremented from the
bytesLoaded and bytesTotal properties !
public function get loadPolicy():ILoadPolicy
public function set loadPolicy(value:ILoadPolicy):void
| nextFileToLoad | property |
nextFileToLoad:ILoadManager [read-only]Defines the next file that will be extracted from the queue to be loaded.
Implementation public function get nextFileToLoad():ILoadManager
| numFilesLoading | property |
numFilesLoading:uint [read-only]
Defines the number of files being currently loaded. This value does not take care if the
Event.OPEN event of each file has been launched. It is based on the
MassLoadEvent.FILE_OPEN event.
public function get numFilesLoading():uint
| parallelFiles | property |
parallelFiles:uint [read-write]Defines the number of files that will be loaded simultaneously. If the value is changed during a load process, this won't affect it.
Implementation public function get parallelFiles():uint
public function set parallelFiles(value:uint):void
| stateIdle | property |
stateIdle:Boolean [read-only]
Defines if the MassLoader is idle.
public function get stateIdle():Boolean
| stateLoading | property |
stateLoading:Boolean [read-only]
Defines if the MassLoader is loading.
public function get stateLoading():Boolean
| useCache | property |
useCache:Boolean [read-write]
Defines if the MassLoader can use the cache or not. Note that if this property
is set to false, it will override all the other ILoadManager.useCache value
and reload them.
public function get useCache():Boolean
public function set useCache(value:Boolean):void
| MassLoader | () | constructor |
public function MassLoader(parallelFiles:uint = 0, useCache:Boolean = true, loadPolicy:ILoadPolicy = null)
Creates a new MassLoader object.
parallelFiles:uint (default = 0) — The number of files to be loaded simultaneously.
|
|
useCache:Boolean (default = true) — Defines if the MassLoader must use the static cache or not.
|
|
loadPolicy:ILoadPolicy (default = null) — The ILoadPolicy to use.
|
| addFile | () | method |
public function addFile(file:ILoadManager):void
Add a file to the loading queue. A file added while the MassLoader
is already running will not be added to the current loading queue. You should stop
and restart the MassLoader in order to include the file into the loading.
file:ILoadManager — The file to add.
|
— If the file is already into the loading queue.
|
See also
| clear | () | method |
public function clear():voidEmpty the loading queue. This will not affect the current loading.
| getFileCount | () | method |
public function getFileCount():uintGet the number of files to be loaded.
Returnsuint — The number of file to load.
|
| getFiles | () | method |
public function getFiles():ArrayGet the files that will be loaded.
ReturnsArray — An Array containing the files to load.
|
| hasFile | () | method |
public function hasFile(file:ILoadManager):BooleanRetrieves if a file is contained into the loading queue.
Parametersfile:ILoadManager — The ILoadManager.
|
Boolean — true if the file is into the loading queue.
|
| isComplete | () | method |
protected function isComplete():Boolean
Defines if the massive loading is complete. This method will return true if there is no more
file into the loading queue and there is currently no file loading.
Boolean — true if all the files are loaded.
|
See also
| loadFile | () | method |
protected final function loadFile(file:ILoadManager):BooleanStart the loading of a file. The file specified will not be removed from the loading queue !
Parametersfile:ILoadManager — The ILoadManager to load.
|
Boolean — true if the loading has been started.
|
| loadNextFile | () | method |
protected function loadNextFile():ILoadManager
Start the loading of the next file. If there is no more file to load,
then a null value is returned. Before the next file is being loaded,
it is removed from the loading queue.
ILoadManager —
The ILoadManager object being loaded or null.
|
| onClose | () | method |
protected final function onClose(evt:Event):void
Event.CLOSE listener.
evt:Event — The event object.
|
| onComplete | () | method |
protected final function onComplete(evt:Event):void
Event.COMPLETE listener.
evt:Event — The event object.
|
| onIOError | () | method |
protected final function onIOError(evt:IOErrorEvent):void
IOErrorEvent.IO_ERROR listener.
evt:IOErrorEvent — The event object.
|
| onOpen | () | method |
protected final function onOpen(evt:Event):void
Event.OPEN listener. If the MassLoader has not been closed,
the current file being open will be added to the filesLoading list.
evt:Event — The event object.
|
| onProgress | () | method |
protected final function onProgress(evt:ProgressEvent):void
ProgressEvent.PROGRESS listener.
evt:ProgressEvent — The event object.
|
| onSecurityError | () | method |
protected final function onSecurityError(evt:SecurityErrorEvent):void
SecurityError.SECURITY_ERROR listener.
evt:SecurityErrorEvent — The event object.
|
| processPolicy | () | method |
protected function processPolicy(file:ILoadManager, closeEvent:Event):ILoadManagerProcesses the loading policy on the currently closed file.
Parametersfile:ILoadManager — The ILoadManager just closed.
|
|
closeEvent:Event — The event that occured.
|
ILoadManager —
The ILoadManager that must be reloaded or null.
|
| registerTo | () | method |
protected function registerTo(file:ILoadManager):void
Register the MassLoader to the specified ILoadManager
object's events.
file:ILoadManager — The file to register to.
|
See also
| removeFile | () | method |
public function removeFile(file:ILoadManager):voidRemoves a file from the loading queue.
Parametersfile:ILoadManager — The file to remove.
|
— If the file is not into the loading queue.
|
See also
| start | () | method |
public final function start():void
Starts downloading data from the specified ILoadableFile objects.
— If the MassLoader is already loading.
|
| startLoading | () | method |
protected function startLoading():void
Start the loading of the files. This method will launch the loading of the files (using
the loadNextFile() method). The number of loading launched is determined by
the parallelFiles value.
See also
| stop | () | method |
public final function stop():voidStops the load operation in progress. Any load operation in progress is immediately terminated.
— If the MassLoader is not loading.
|
| toString | () | method |
public override function toString():String
Lists all the files contained into this MassLoader into a String.
String — A String containing all the files.
|
| unregisterFrom | () | method |
protected function unregisterFrom(file:ILoadManager):void
Unregister the MassLoader from the specified ILoadManager
object's events.
file:ILoadManager — The file to unregister from.
|
See also
| updateBytes | () | method |
protected final function updateBytes():void
Updates the bytesLoaded and bytesTotal values.
| close | event |
flash.events.Event
Dispatched when the download operation stops. This is following a call to the MassLoader.stop()
method.
| complete | event |
| fileClose | event |
ch.capi.events.MassLoadEvent
Dispatched when the loading of a ILoadManager is closed (eg when the loading is complete or
an error has occured).
| fileOpen | event |
ch.capi.events.MassLoadEvent
Dispatched when the MassLoader starts the loading of a file. This event
is dispatched just before the ILoadManager.start() method is called.
| open | event |
flash.events.Event
Dispatched when the download operation commences following a call to the MassLoader.load()
method.
| progress | event |
flash.events.ProgressEvent
Dispatched when data is received as the download operation progresses. The bytesTotal and bytesLoaded
value are based on the overall progressing of the files stored into the loading queue. If the bytesTotal of a
ILoadableFile has not been retrieved, then the virtualBytesTotal value will be used.