Package | ch.capi.net |
Class | public class PriorityMassLoader |
Inheritance | PriorityMassLoader MassLoader GlobalEventDispatcher flash.events.EventDispatcher |
Implements | IMassLoader |
Subclasses | ApplicationMassLoader |
loadByPriority
value).
To sort the files by priority, the PriorityMassLoader
will use a ArrayHeap
object as
filesQueue
data structure.
See also
Property | Defined By | ||
---|---|---|---|
alwaysDispatchProgressEvent : Boolean = true
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 MassLoader (Event.CLOSE or Event.COMPLETE). | MassLoader | ||
currentPriority : int [read-only]
Defines the current priority of the files that are being loaded. | PriorityMassLoader | ||
defaultPriority : int = 0
Defines the default priority to use for the addFile method. | PriorityMassLoader | ||
dispatchGlobalEvents : Boolean
Defines if the global events must be dispatched or not. | GlobalEventDispatcher | ||
loadByPriority : Boolean
Defines if the loading is done by priority. | PriorityMassLoader | ||
loaded : Boolean [read-only]
Defines if the ILoadManager operation is 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 | ||
numFiles : uint [read-only]
Defines the total of the files in the MassLoader. | MassLoader | ||
numFilesLoaded : uint [read-only]
Defines the number of files loaded. | MassLoader | ||
numFilesLoading : uint [read-only]
Defines the number of files being currently loaded. | MassLoader | ||
numFilesOpen : uint [read-only]
Defines the number of files being currently open. | MassLoader | ||
numFilesToLoad : uint [read-only]
Defines the number of files to load. | 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 |
Method | Defined By | ||
---|---|---|---|
PriorityMassLoader(parallelFiles:uint = 0, loadByPriority:Boolean = false)
Creates a new PriorityMassLoader object. | PriorityMassLoader | ||
addFile(file:ILoadManager):void
Add the specified file in the loading queue with the default priority. | PriorityMassLoader | ||
addPrioritizedFile(file:ILoadManager, priority:int = 0):void
Add a file with a specific priority in the loading queue. | PriorityMassLoader | ||
clear():void
Clear the loading queues and files priorities. | PriorityMassLoader | ||
dispatchEvent(evt:Event):Boolean
Dispatches the specified Event through the listeners. | GlobalEventDispatcher | ||
getFileCount():uint
Get the number of files to be loaded. | MassLoader | ||
getFilePriority(file:ILoadManager):int
Retreives the priority of a ILoadManager object. | PriorityMassLoader | ||
getFiles():Array
Get the files that will be loaded. | MassLoader | ||
getFilesAtPriority(priority:int):Array
Defines the files to be loaded at the specified priority. | PriorityMassLoader | ||
getStaticIndexOf(file:ILoadManager):int
Retrieves the static index of the specified ILoadManager. | MassLoader | ||
hasFile(file:ILoadManager):Boolean
Retrieves if a file is contained in the loading queue. | MassLoader | ||
removeFile(file:ILoadManager):void
Removes the specified file from the loading queue. | PriorityMassLoader | ||
setFilePriority(file:ILoadManager, priority:int):void
Set a file priority of a ILoadManager object. | PriorityMassLoader | ||
start():Boolean
Starts downloading data from the specified ILoadManager objects. | MassLoader | ||
stop():void
Stops the load operation in progress. | MassLoader | ||
toString():String
Lists all the files contained in this PriorityMassLoader in a String. | PriorityMassLoader |
Method | Defined By | ||
---|---|---|---|
Creates a MassLoadEvent based on the specified ILoadManager. | PriorityMassLoader | ||
getFileQueueIndex(file:ILoadManager):int
Retrieves the index of a file in the loading queue (if the loading of the specified file has been started). | MassLoader | ||
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 | ||
Process the loading policy on the currently file that is being open. | MassLoader | ||
registerTo(file:ILoadManager):void
Register the MassLoader to the specified ILoadManager
object's events. | MassLoader | ||
Determines which file must be loaded first. | PriorityMassLoader | ||
startLoading():void
Start the loading of the files. | PriorityMassLoader | ||
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 loading of a ILoadManager progresses. | MassLoader | |||
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. | MassLoader | |||
Dispatched when the loading of files with a lower priority starts. | PriorityMassLoader | |||
Dispatched when data is received as the download operation progresses. | MassLoader |
currentPriority | property |
currentPriority:int
[read-only] Defines the current priority of the files that are being loaded.
public function get currentPriority():int
defaultPriority | property |
public var defaultPriority:int = 0
Defines the default priority to use for the addFile
method.
See also
loadByPriority | property |
loadByPriority:Boolean
[read-write]
Defines if the loading is done by priority. By default, this value is false
.
If this value is false
then the files
will be loaded directly in the priority order but will not take care of the change of the priority.
If this value is true
, then the parallelFiles
value will not be used.
If this value is changed after some files have been added to the loading queue, the order won't be the same as they were added (data structure updated)
public function get loadByPriority():Boolean
public function set loadByPriority(value:Boolean):void
See also
PriorityMassLoader | () | Constructor |
public function PriorityMassLoader(parallelFiles:uint = 0, loadByPriority:Boolean = false)
Creates a new PriorityMassLoader
object.
parallelFiles:uint (default = 0 ) — Defines how many file to load at the same time. This value will affect the loading only if the
loadByPriority property is false .
| |
loadByPriority:Boolean (default = false ) — Defines if the PriorityMassLoader must load the files by priority. If this value is
true , then the parallelFiles property will be ignored.
|
addFile | () | method |
override public function addFile(file:ILoadManager):void
Add the specified file in the loading queue with the default priority.
Parameters
file:ILoadManager — The ILoadManager .
|
See also
addPrioritizedFile | () | method |
public function addPrioritizedFile(file:ILoadManager, priority:int = 0):void
Add a file with a specific priority in the loading queue.
Parameters
file:ILoadManager — The ILoadManager .
| |
priority:int (default = 0 ) — The priority of the file.
|
clear | () | method |
override public function clear():void
Clear the loading queues and files priorities.
createMassLoadEvent | () | method |
override protected function createMassLoadEvent(file:ILoadManager, type:String, evt:Event = null):MassLoadEvent
Creates a MassLoadEvent
based on the specified ILoadManager
. This method also add
the priority to the MassLoadEvent
.
Parameters
file:ILoadManager — The ILoadManager .
| |
type:String — The MassLoadEvent type. This value can be MassLoadEvent.FILE_OPEN
or MassLoadEvent.FILE_CLOSE .
| |
evt:Event (default = null ) — The close event, if any.
|
MassLoadEvent — The created MassLoadEvent .
|
getFilePriority | () | method |
public function getFilePriority(file:ILoadManager):int
Retreives the priority of a ILoadManager
object.
Parameters
file:ILoadManager — The file to get the priority.
|
int — The priority or 0 if the file isn't in the loading queue.
|
See also
getFilesAtPriority | () | method |
public function getFilesAtPriority(priority:int):Array
Defines the files to be loaded at the specified priority.
Parameters
priority:int — The priority.
|
Array — The files that will be loaded at the specified priority.
|
removeFile | () | method |
override public function removeFile(file:ILoadManager):void
Removes the specified file from the loading queue.
Parameters
file:ILoadManager — The ILoadManager .
|
setFilePriority | () | method |
public function setFilePriority(file:ILoadManager, priority:int):void
Set a file priority of a ILoadManager
object. Note that changing the priority
of a file if the PriorityMassLoader
is already loading won't affect it.
Parameters
file:ILoadManager — The file to set the priority.
| |
priority:int — The new priority of the file.
|
IllegalOperationError If — the file is not in the loading queue.
|
sortFiles | () | method |
protected function sortFiles(a:ILoadManager, b:ILoadManager):int
Determines which file must be loaded first. This method will return 0 if one of both
arguments is not a ILoadableFile
, otherwise it retrieves the priority value
from the properties and compare them.
Parameters
a:ILoadManager — A ILoadManager .
| |
b:ILoadManager — A ILoadManager .
|
int — An int greater than 0 if b must be loaded before a .
|
See also
startLoading | () | method |
override protected function startLoading():void
Start the loading of the files.
If the loadByPriority
value is true
,
then, the method will retrieves the next file, checks his priority and start the loading of all
the files with the same one. In that case, a PriorityEvent.PRIORITY_CHANGED
event
will be dispatched. If the loadByPriority
value is false
, it will
retrieves the files by priority and start the loading of the value specified in the parallelFiles
property.
If there is file currently being loaded or the filesQueue
is empty, this method does
nothing.
See also
toString | () | method |
override public function toString():String
Lists all the files contained in this PriorityMassLoader
in a String
.
String — A String containing all the files.
|
priorityChanged | Event |
ch.capi.events.PriorityEvent
ch.capi.events.PriorityEvent.PRIORITY_CHANGED
Dispatched when the loading of files with a lower priority starts. This event
will be dispatched only if the value of loadByPriority
is true
.
See also
var lf:LoadableFileFactory = new LoadableFileFactory(); var file1:ILoadableFile = lf.create("myFile.txt"); var file2:ILoadableFile = lf.create("myAnim.swf"); var file3:ILoadableFile = lf.create("otherFile.xml"); var ml:PriorityMassLoader = new PriorityMassLoader(); ml.addPriorizedFile(file1, 15); ml.addPriorizedFile(file2, 15); ml.addFile(file3); //priority of 0 by default var eventFile:Function = function(evt:MassLoadEvent):void { var src:ILoadableFile = (evt.file as ILoadableFile); trace(evt.type+" => "+src); } ml.addEventListener(MassLoadEvent.FILE_OPEN, eventFile); ml.addEventListener(MassLoadEvent.FILE_CLOSE, eventFile); ml.start();