Package | ch.capi.net |
Class | public class CompositeMassLoader |
Inheritance | CompositeMassLoader GlobalEventDispatcher flash.events.EventDispatcher |
Implements | ICompositeMassLoader |
PriorityMassLoader
and LoadableFileFactory
to create
the ILoadableFile
and for the loading management.
It is an encapsulation class to the Masapi API core functions. It is also a basic implementation
of a ICompositeMassLoader
.
The CompositeMassLoader
keeps by default a reference to the created ILoadableFile
(see the keepFiles
property).
See also
Property | Defined By | ||
---|---|---|---|
dispatchGlobalEvents : Boolean
Defines if the global events must be dispatched or not. | GlobalEventDispatcher | ||
keepFiles : Boolean [read-only]
Defines if the CompositeMassLoader must keep references on the created
ILoadableFile instances. | CompositeMassLoader | ||
loadableFileFactory : LoadableFileFactory
Defines the LoadableFileFactory to use. | CompositeMassLoader | ||
massLoader : IMassLoader [read-only]
Defines the PriorityMassLoader to use. | CompositeMassLoader | ||
name : String [read-only]
Defines the name of the CompositeMassLoader. | CompositeMassLoader |
Method | Defined By | ||
---|---|---|---|
CompositeMassLoader(name:String = null, parallelFiles:int = 1, register:Boolean = true)
Creates a new CompositeMassLoader object. | CompositeMassLoader | ||
addFile(fileOrURL:Object, fileType:String = null, priority:Function = null, onOpen:Function = null, onProgress:Function = null, onComplete:Function = null, onClose:Function = null, onIOError:Function = null, onSecurityError:* = null):ILoadableFile
Creates a ILoadableFile from a url and add it to the current loading queue. | CompositeMassLoader | ||
clear(destroyAll:Boolean = true):void
Clears the loading queue of the IMassLoader and empty the references to the
created ILoadableFile instances. | CompositeMassLoader | ||
createFile(fileOrURL:Object, fileType:String = null, onOpen:Function = null, onProgress:Function = null, onComplete:Function = null, onClose:Function = null, onIOError:Function = null, onSecurityError:Function = null):ILoadableFile
Creates a ILoadableFile from a url. | CompositeMassLoader | ||
dispatchEvent(evt:Event):Boolean
Dispatches the specified Event through the listeners. | GlobalEventDispatcher | ||
getFileAt(index:uint):ILoadableFile
Retrieves the ILoadableFile at the specified index. | CompositeMassLoader | ||
getFileByProps(props:Object, strict:Boolean = false):ILoadableFile
Retrieves the first file that matches the specified properties. | CompositeMassLoader | ||
getFileCount():uint
Retrieves the number of ILoadableFile instances that have been stored. | CompositeMassLoader | ||
getFiles():Array
Retrieves all the files created by the CompositeMassLoader. | CompositeMassLoader | ||
getFilesByProps(props:Object, strict:Boolean = false):Array
Retrieves all the files that matche the specified properties. | CompositeMassLoader | ||
start(noCache:Boolean = false):void
Starts the loading of the massive loader. | CompositeMassLoader | ||
stop():void
Stops the loading of the massive loader. | CompositeMassLoader |
Method | Defined By | ||
---|---|---|---|
createLoadableFile(request:URLRequest, fileType:String = null):ILoadableFile
Retrieves a ILoadableFile from a URLRequest and and a specified file type
issued from the LoadableFileType constants. | CompositeMassLoader | ||
eventRedirector(evt:Event):void
Redirects all the events that it received. | CompositeMassLoader | ||
registerTo(massLoader:IMassLoader):void
Register as listener to the specified IMassLoader. | CompositeMassLoader | ||
storeFile(file:ILoadableFile):void
Stores the specified ILoadableFile. | CompositeMassLoader | ||
unregisterFrom(massLoader:IMassLoader):void
Unregister from the specified IMassLoader. | CompositeMassLoader |
Event | Summary | Defined By | ||
---|---|---|---|---|
Dispatched when the download operation stops. | CompositeMassLoader | |||
Dispatched after all the files have been downloaded, even if errors occured. | CompositeMassLoader | |||
Dispatched when the loading of a ILoadManager is closed (eg when the loading is complete or an error has occured). | CompositeMassLoader | |||
Dispatched when the MassLoader starts the loading of a file. | CompositeMassLoader | |||
Dispatched when the loading of a ILoadManager progresses. | CompositeMassLoader | |||
Dispatched after an event is dispatched. | GlobalEventDispatcher | |||
Dispatched before an event is dispatched. | GlobalEventDispatcher | |||
Dispatched when the download operation commences following a call to the MassLoader.start() method. | CompositeMassLoader | |||
Dispatched when the loading of files with a lower priority starts. | CompositeMassLoader | |||
Dispatched when data is received as the download operation progresses. | CompositeMassLoader |
keepFiles | property |
keepFiles:Boolean
[read-only]
Defines if the CompositeMassLoader
must keep references on the created
ILoadableFile
instances. If this is set to false
, a reference must
be kept on the ILoadableFile
to prevent the Garbage Collector to delete them.
public function get keepFiles():Boolean
See also
loadableFileFactory | property |
loadableFileFactory:LoadableFileFactory
[read-write]
Defines the LoadableFileFactory
to use.
public function get loadableFileFactory():LoadableFileFactory
public function set loadableFileFactory(value:LoadableFileFactory):void
massLoader | property |
massLoader:IMassLoader
[read-only]
Defines the PriorityMassLoader
to use.
public function get massLoader():IMassLoader
name | property |
name:String
[read-only]
Defines the name of the CompositeMassLoader
. If the name is
null
, then the CompositeMassLoader
is not registered
in the global map.
public function get name():String
See also
CompositeMassLoader | () | Constructor |
public function CompositeMassLoader(name:String = null, parallelFiles:int = 1, register:Boolean = true)
Creates a new CompositeMassLoader
object.
name:String (default = null ) — The name of the CompositeMassLoader . That name must be unique. If no name is defined, then
the instance won't be registered.
| |
parallelFiles:int (default = 1 ) — The number of files to load at the same time.
| |
register:Boolean (default = true ) — Defines if the CompositeMassLoader must be automatically registered in the
CompositeMassLoaderRegisterer class.
|
addFile | () | method |
public function addFile(fileOrURL:Object, fileType:String = null, priority:Function = null, onOpen:Function = null, onProgress:Function = null, onComplete:Function = null, onClose:Function = null, onIOError:Function = null, onSecurityError:* = null):ILoadableFile
Creates a ILoadableFile
from a url and add it to the current loading queue. If the fileOrURL parameter is an object,
all the properties will be put in the ILoadableFile.properties
attribute of the created ILoadableFile
.
Parameters
fileOrURL:Object — The url of the file or an Object containing at least the 'url' attribute.
| |
fileType:String (default = null ) — The type of the file. If not defined and the fileOrURL parameter is an Object , then
the type will be extracted from the attribute 'type'.
| |
priority:Function (default = null ) — The priority of the file (must be an int). If not defined and the fileOrURL parameter is an Object , then
the priority of the file will be extracted from the attribute 'priority'. If no priority is specified, then the
priority will be 0.
| |
onOpen:Function (default = null ) — The Event.OPEN listener.
| |
onProgress:Function (default = null ) — The ProgressEvent.PROGRESS listener.
| |
onComplete:Function (default = null ) — The Event.COMPLETE listener.
| |
onClose:Function (default = null ) — The Event.CLOSE listener.
| |
onIOError:Function (default = null ) — The IOErrorEvent.IO_ERROR listener.
| |
onSecurityError:* (default = null ) — The SecurityErrorEvent.SECURITY_ERROR listener.
|
ILoadableFile — The created ILoadableFile .
|
ArgumentError If — fileOrURl is null .
| |
ArgumentError If — the priority is invalid.
|
See also
var cm:CompositeMassLoader = new CompositeMassLoader(false); //those three lines have the same behavior cm.addFile("myAnimation.swf", LoadableFileType.BINARY, 10); cm.addFile({url:"myAnimation.swf", type:LoadableFileType.BINARY, priority:10}); cm.addFile(new URLRequest("myAnimation.swf"), LoadableFileType.BINARY, 10);
clear | () | method |
public function clear(destroyAll:Boolean = true):void
Clears the loading queue of the IMassLoader
and empty the references to the
created ILoadableFile
instances.
Parameters
destroyAll:Boolean (default = true ) — If true , then the destroy() method will
be called on all the ILoadableFile .
|
See also
createFile | () | method |
public function createFile(fileOrURL:Object, fileType:String = null, onOpen:Function = null, onProgress:Function = null, onComplete:Function = null, onClose:Function = null, onIOError:Function = null, onSecurityError:Function = null):ILoadableFile
Creates a ILoadableFile
from a url. This method doesn't register the file to the IMassLoader
but
it stores it in the CompositeMassLoader
. If the fileOrURL parameter is an object, all the properties will
be put in the ILoadableFile.properties
attribute of the created ILoadableFile
.
Parameters
fileOrURL:Object — The url of the file or an Object containing at least the 'url' attribute.
| |
fileType:String (default = null ) — The type of the file. If not defined and the fileOrURL parameter is an Object , then
the type will be extracted from the attribute 'type'.
| |
onOpen:Function (default = null ) — The Event.OPEN listener.
| |
onProgress:Function (default = null ) — The ProgressEvent.PROGRESS listener.
| |
onComplete:Function (default = null ) — The Event.COMPLETE listener.
| |
onClose:Function (default = null ) — The Event.CLOSE listener.
| |
onIOError:Function (default = null ) — The IOErrorEvent.IO_ERROR listener.
| |
onSecurityError:Function (default = null ) — The SecurityErrorEvent.SECURITY_ERROR listener.
|
ILoadableFile — The created ILoadableFile .
|
ArgumentError if — the fileOrURL parameter is not defined.
|
See also
var cm:CompositeMassLoader = new CompositeMassLoader(false); //those three lines have the same behavior cm.createFile("myAnimation.swf", LoadableFileType.BINARY); cm.createFile({url:"myAnimation.swf", type:LoadableFileType.BINARY}); cm.createFile(new URLRequest("myAnimation.swf"), LoadableFileType.BINARY);
createLoadableFile | () | method |
protected function createLoadableFile(request:URLRequest, fileType:String = null):ILoadableFile
Retrieves a ILoadableFile
from a URLRequest
and and a specified file type
issued from the LoadableFileType
constants.
Parameters
request:URLRequest — The URLRequest .
| |
fileType:String (default = null ) — The type of the file.
|
ILoadableFile — The ILoadableFile created.
|
ArgumentError If — the fileType is not valid.
|
See also
eventRedirector | () | method |
protected function eventRedirector(evt:Event):void
Redirects all the events that it received. This method acts like a proxy : it is attached
to a IMassLoader
as event listener and all the events are redispatched through
the CompositeMassLoader
. Note that all the events are cloned before redirection.
Parameters
evt:Event — The Event object.
|
getFileAt | () | method |
public function getFileAt(index:uint):ILoadableFile
Retrieves the ILoadableFile
at the specified index.
Parameters
index:uint — The index.
|
ILoadableFile — The ILoadableFile .
|
getFileByProps | () | method |
public function getFileByProps(props:Object, strict:Boolean = false):ILoadableFile
Retrieves the first file that matches the specified properties.
Parameters
props:Object — An Object containing the properties to match.
| |
strict:Boolean (default = false ) — Defines if the check must be strict or not.
|
ILoadableFile — The first ILoadableFile instance that matches the properties
or null .
|
See also
getFileCount | () | method |
public function getFileCount():uint
Retrieves the number of ILoadableFile
instances that have been stored.
uint — The number of stored ILoadableFile .
|
getFiles | () | method |
public function getFiles():Array
Retrieves all the files created by the CompositeMassLoader
. Note that the CompositeMassLoader
register the files only if the keepFiles
property is set to true
.
Array — The created ILoadableFile .
|
getFilesByProps | () | method |
public function getFilesByProps(props:Object, strict:Boolean = false):Array
Retrieves all the files that matche the specified properties.
Parameters
props:Object — An Object containing the properties to match.
| |
strict:Boolean (default = false ) — Defines if the check must be strict or not.
|
Array — An Array of ILoadableFile that match the
specified properties.
|
See also
registerTo | () | method |
protected function registerTo(massLoader:IMassLoader):void
Register as listener to the specified IMassLoader
.
Parameters
massLoader:IMassLoader — The IMassLoader to listen.
|
start | () | method |
public function start(noCache:Boolean = false):void
Starts the loading of the massive loader.
Parameters
noCache:Boolean (default = false ) — If true , then all the files contained in this
ICompositeMassLoader will be added back in the IMassLoader
to be reloaded. This cache has nothing to do with the useCache
property of a ILoadableFile . Moreover, this parameter will have an effect
only if the keepFiles property is true .
|
See also
stop | () | method |
storeFile | () | method |
protected function storeFile(file:ILoadableFile):void
Stores the specified ILoadableFile
.
Parameters
file:ILoadableFile — The file to store.
|
unregisterFrom | () | method |
protected function unregisterFrom(massLoader:IMassLoader):void
Unregister from the specified IMassLoader
.
Parameters
massLoader:IMassLoader — The IMassLoader to stop to listen to.
|
close | Event |
flash.events.Event
flash.events.Event.CLOSE
Dispatched when the download operation stops. This is following a call to the MassLoader.stop()
method.
See also
complete | Event |
flash.events.Event
flash.events.Event.COMPLETE
Dispatched after all the files have been downloaded, even if errors occured.
See also
fileClose | Event |
ch.capi.events.MassLoadEvent
ch.capi.events.MassLoadEvent.FILE_CLOSE
Dispatched when the loading of a ILoadManager
is closed (eg when the loading is complete or
an error has occured).
See also
fileOpen | Event |
ch.capi.events.MassLoadEvent
ch.capi.events.MassLoadEvent.FILE_OPEN
Dispatched when the MassLoader
starts the loading of a file. This event
is dispatched just before the ILoadManager.start()
method is called.
See also
fileProgress | Event |
ch.capi.events.MassLoadEvent
ch.capi.events.MassLoadEvent.FILE_PROGRESS
Dispatched when the loading of a ILoadManager
progresses.
open | Event |
flash.events.Event
flash.events.Event.OPEN
Dispatched when the download operation commences following a call to the MassLoader.start()
method.
See also
priorityChanged | Event |
ch.capi.events.PriorityEvent
ch.capi.events.PriorityEvent.PRIORITY_CHANGED
Dispatched when the loading of files with a lower priority starts.
Event when the priority changes.See also
progress | Event |
flash.events.ProgressEvent
flash.events.ProgressEvent.PROGRESS
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 in the loading queue. If the bytesTotal
of a
ILoadableFile
has not been retrieved, then the virtualBytesTotal
value will be used.
See also
CompositeMassLoader
keep a reference to the created files by default :
var cm:CompositeMassLoader = new CompositeMassLoader(); cm.addFile("myAnimation.swf"); cm.addFile("otherSWF.swf", LoadableFileType.BINARY); cm.addFile({url:"otherSWF.swf", type:LoadableFileType.BINARY, priority:30}); cm.addFile("myVariables.txt", LoadableFileType.TEXT, 10); cm.start();