Packagech.capi.net
Classpublic class CompositeMassLoader
SubclassesCompositePriorityMassLoader

This is a utility class to avoid too much verbose code within the masapi API. Note that this class simply uses the IMassLoader and LoadableFileFactory to creates the ILoadableFile and for the loading management.

The CompositeMassLoader keeps by default a reference to the created ILoadableFile (see the keepFiles property).


Example
The 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("myVariables.txt");
  
  cm.start();
  

The CompositeMassLoader doesn't keep a reference to the created files :
  var cm:CompositeMassLoader = new CompositeMassLoader(false);
  var file1:ILoadableFile = cm.addFile("myAnimation.swf");
  var file2:ILoadableFile = cm.addFile("otherSWF.swf", LoadableFileType.BINARY);
  var file3:ILoadableFile = cm.addFile("myVariables.txt");
  
  cm.start();
  

See also

LoadableFileFactory
IMassLoader


Public Properties
 PropertyDefined by
  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
Defines the IMassLoader to use.
CompositeMassLoader
Public Methods
 MethodDefined by
  
CompositeMassLoader(keepFiles:Boolean = true, massLoader:IMassLoader = null, loadableFileFactory:LoadableFileFactory = null)
Creates a new CompositeMassLoader object.
CompositeMassLoader
  
addFile(url:String, 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 and add it to the current loading queue.
CompositeMassLoader
  
addRequest(request:URLRequest, 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 URLRequest and add it to the current loading queue.
CompositeMassLoader
  
clear():void
Clears the loading queue of the IMassLoader and empty the references to the created ILoadableFile instances.
CompositeMassLoader
  
createFile(url:String, 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
  
getFileAt(index:uint):ILoadableFile
Retrieves the ILoadableFile at the specified index.
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
  
start():void
Starts the loading of the massive loader.
CompositeMassLoader
  
stop():void
Stops the loading of the massive loader.
CompositeMassLoader
Protected Methods
 MethodDefined 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
  
Stores the specified ILoadableFile.
CompositeMassLoader
Property detail
keepFilesproperty
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.

Implementation
    public function get keepFiles():Boolean

See also

loadableFileFactoryproperty 
loadableFileFactory:LoadableFileFactory  [read-write]

Defines the LoadableFileFactory to use.

Implementation
    public function get loadableFileFactory():LoadableFileFactory
    public function set loadableFileFactory(value:LoadableFileFactory):void
massLoaderproperty 
massLoader:IMassLoader  [read-write]

Defines the IMassLoader to use.

Implementation
    public function get massLoader():IMassLoader
    public function set massLoader(value:IMassLoader):void
Constructor detail
CompositeMassLoader()constructor
public function CompositeMassLoader(keepFiles:Boolean = true, massLoader:IMassLoader = null, loadableFileFactory:LoadableFileFactory = null)

Creates a new CompositeMassLoader object.

Parameters
keepFiles:Boolean (default = true) — If the CompositeMassLoader must keep a reference on the created ILoadableFile instances.
 
massLoader:IMassLoader (default = null) — The IMassLoader to use.
 
loadableFileFactory:LoadableFileFactory (default = null) — The LoadableFileFactory to use.
Method detail
addFile()method
public function addFile(url:String, 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 and add it to the current loading queue.

Parameters
url:String — url The url of the file.
 
fileType:String (default = null) — The type of the file.
 
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.

Returns
ILoadableFile — The created ILoadableFile.
addRequest()method 
public function addRequest(request:URLRequest, 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 URLRequest and add it to the current loading queue.

Parameters
request:URLRequest — The URLRequest.
 
fileType:String (default = null) — The type of the file.
 
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.

Returns
ILoadableFile — The created ILoadableFile.
clear()method 
public function clear():void

Clears the loading queue of the IMassLoader and empty the references to the created ILoadableFile instances.

See also

createFile()method 
public function createFile(url:String, 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 into the CompositeMassLoader.

Parameters
url:String — url The url of the file.
 
fileType:String (default = null) — The type of the file.
 
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.

Returns
ILoadableFile — The created ILoadableFile.
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.

Returns
ILoadableFile — The ILoadableFile created.

Throws
— If the fileType is not valid.

See also

LoadableFileType
IFileSelector
getFileAt()method 
public function getFileAt(index:uint):ILoadableFile

Retrieves the ILoadableFile at the specified index.

Parameters
index:uint — The index.

Returns
ILoadableFile — The ILoadableFile.
getFileCount()method 
public function getFileCount():uint

Retrieves the number of ILoadableFile instances that have been stored.

Returns
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.

Returns
Array — The created ILoadableFile.
start()method 
public function start():void

Starts the loading of the massive loader.

See also

stop()method 
public function stop():void

Stops the loading of the massive loader.

See also

storeFile()method 
protected function storeFile(file:ILoadableFile):void

Stores the specified ILoadableFile.

Parameters
file:ILoadableFile — The file to store.