Package | ch.capi.net |
Class | public class PriorityMassLoader |
Inheritance | PriorityMassLoader MassLoader 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.
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.urlRequest.url); } ml.addEventListener(MassLoadEvent.FILE_OPEN, eventFile); ml.addEventListener(MassLoadEvent.FILE_CLOSE, eventFile); 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
Defines the bytes that have been loaded.
| MassLoader | ||
bytesTotal : uint
Defines the total bytes to load.
| MassLoader | ||
closeEvent : Event
Defines the event that happend to close the file (Event.CLOSE, 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 | ||
loadByPriority : Boolean = true
Defines if the loading is done by priority.
| PriorityMassLoader | ||
loadInfo : ILoadInfo
Defines the
ILoadInfo object linked to the IMassLoader . | MassLoader | ||
loadPolicy : ILoadPolicy
Defines the
ILoadPolicy to use. | MassLoader | ||
nextFileToLoad : ILoadManager
Defines the next file that will be extracted from the queue to be loaded.
| MassLoader | ||
numFilesLoading : uint
Defines the number of files being currently loaded.
| MassLoader | ||
parallelFiles : uint
Defines the number of files that will be loaded simultaneously.
| MassLoader | ||
stateIdle : Boolean
Defines if the
MassLoader is idle. | MassLoader | ||
stateLoading : Boolean
Defines if the
MassLoader is loading. | MassLoader | ||
useCache : Boolean
Defines if the
MassLoader can use the cache or not. | MassLoader |
Method | Defined by | ||
---|---|---|---|
Creates a new
PriorityMassLoader object. | PriorityMassLoader | ||
addFile(file:ILoadManager):void
Add the specified file into the loading queue with the specified
defaultPriority . | PriorityMassLoader | ||
addPrioritizedFile(file:ILoadManager, priority:int = 0):void
Add a file with a specific priority into the loading queue.
| PriorityMassLoader | ||
clear():void
Empty the loading queue.
| MassLoader | ||
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 | ||
hasFile(file:ILoadManager):Boolean
Retrieves if a file is contained into the loading queue.
| MassLoader | ||
removeFile(file:ILoadManager):void
Removes the specified file from the loading queue.
| PriorityMassLoader | ||
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
PriorityMassLoader into a String . | PriorityMassLoader |
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 | ||
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 download operation commences following a call to the MassLoader.load()
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.
Implementation 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 |
public var loadByPriority:Boolean = true
Defines if the loading is done by priority. If this value is false
then the files
will be loaded directly into 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.
PriorityMassLoader | () | constructor |
public function PriorityMassLoader()
Creates a new PriorityMassLoader
object.
addFile | () | method |
public override function addFile(file:ILoadManager):void
Add the specified file into the loading queue with the specified
defaultPriority
. To specify the file priority manually,
use the addPriorizedFile
method.
file:ILoadManager — The ILoadManager .
|
See also
addPrioritizedFile | () | method |
public function addPrioritizedFile(file:ILoadManager, priority:int = 0):void
Add a file with a specific priority into the loading queue.
Parametersfile:ILoadManager — The ILoadManager .
|
|
priority:int (default = 0 ) — The priority of the file.
|
getFilePriority | () | method |
public function getFilePriority(file:ILoadManager):int
Retreives the priority of a ILoadManager
object. In order to change the
priority of a file, simple remove it and readd it using the addPriorizedFile
method.
file:ILoadManager — The file to get the priority.
|
int — The priority or 0 if the file isn't into the loading queue.
|
See also
removeFile | () | method |
public override function removeFile(file:ILoadManager):void
Removes the specified file from the loading queue.
Parametersfile:ILoadManager — The ILoadManager .
|
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.
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 |
protected override 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 into the parallelFiles
property.
If there is file currently being loaded or the filesQueue
is empty, this method does
nothing.
See also
toString | () | method |
public override function toString():String
Lists all the files contained into this PriorityMassLoader
into a String
.
String — A String containing all the files.
|
priorityChanged | event |
ch.capi.events.PriorityEvent
Dispatched when the loading of files with a lower priority starts. This event
won't be dispatched if the value of loadByPriority
is false
.
See also