Packagech.capi.net.files
Classpublic class AbstractLoadableFile
InheritanceAbstractLoadableFile Inheritance GlobalEventDispatcher Inheritance flash.events.EventDispatcher
Implements INetStateManager
Subclasses LoaderFile, SoundFile, URLLoaderFile, URLStreamFile

Represents a AbstractLoadableFile. This is a basic implementation to store the generic data of a ILoadableFile.

See also

ILoadableFile
LoadableFileFactory


Public Properties
 PropertyDefined By
  bytesLoaded : uint
[read-only] Defines the bytes that have been loaded.
AbstractLoadableFile
  bytesTotal : uint
[read-only] Defines the total bytes to load.
AbstractLoadableFile
  bytesTotalRetrieved : Boolean
[read-only] Defines if the bytesTotal have been retrieved.
AbstractLoadableFile
  closeEvent : Event
[read-only] Defines the event that happend to close the file (Event.CLOSE, Event.COMPLETE, ...).
AbstractLoadableFile
 InheriteddispatchGlobalEvents : Boolean
Defines if the global events must be dispatched or not.
GlobalEventDispatcher
  fixedRequest : URLRequest
[read-only] Defines the URLRequest that has been loaded by the ILoadableFile.
AbstractLoadableFile
  loaded : Boolean
[read-only] Defines if the ILoadManager operation is complete.
AbstractLoadableFile
  loadManagerObject : Object
[read-only] Defines the load manager object.
AbstractLoadableFile
  netState : String
Defines the NetState value.
AbstractLoadableFile
  properties : IProperties
[read-only] Defines the properties stored in the ILoadableFile.
AbstractLoadableFile
  stateIdle : Boolean
[read-only] Defines if the AbstractLoadableFile is idle.
AbstractLoadableFile
  stateLoading : Boolean
[read-only] Defines if the AbstractLoadableFile is loading.
AbstractLoadableFile
  urlRequest : URLRequest
Defines the URLRequest object that specify the URL to load.
AbstractLoadableFile
  urlVariables : IMap
Defines the variables key/values to be replaced in the url before the loading is launched.
AbstractLoadableFile
  useCache : Boolean
Defines if the ILoadManager can use the cache or not.
AbstractLoadableFile
  virtualBytesTotal : uint
Defines the virtual total bytes.
AbstractLoadableFile
Public Methods
 MethodDefined By
  
AbstractLoadableFile(loadManagerObject:Object)
Creates a new AbstractLoadableFile object.
AbstractLoadableFile
  
destroy():void
Destroys this ILoadableFile.
AbstractLoadableFile
 Inherited
dispatchEvent(evt:Event):Boolean
Dispatches the specified Event through the listeners.
GlobalEventDispatcher
  
Invalidate the current fixedRequest.
AbstractLoadableFile
  
isDestroyed():Boolean
Retrieves if this ILoadableFile has been destroyed.
AbstractLoadableFile
  
isOnline():Boolean
Retrieves if the current AbstractLoadableFile is online or not.
AbstractLoadableFile
  
Tells the ILoadableFile to update the fixedRequest value that will be used to load the file.
AbstractLoadableFile
  
start():Boolean
Set the state as loading.
AbstractLoadableFile
  
stop():void
Set the state as idle.
AbstractLoadableFile
  
toString():String
Get the URL of the AbstractLoadableFile.
AbstractLoadableFile
Protected Methods
 MethodDefined By
  
checkData():void
Checks if data has been loaded and is available to be retrieved.
AbstractLoadableFile
  
Checks if the current ILoadableFile has been destroyed and if so, throws an IllegalOperationError.
AbstractLoadableFile
  
Creates a clone of the current URLRequest and put the variables values in its data.
AbstractLoadableFile
  
getURLRequest():URLRequest
Retrieves the URLRequest that is created depending of the useCache property value.
AbstractLoadableFile
  
isInstanceOf(source:String, superClasses:Array, appDomain:ApplicationDomain = null):Boolean
Checks if the specified source class is a child of one of the specified super classes.
AbstractLoadableFile
  
isInstanceOfClass(source:String, superClass:String, appDomain:ApplicationDomain = null):Boolean
Checks if the specified source class is a child of the specified super class.
AbstractLoadableFile
  
onComplete(evt:Event):void
Event.COMPLETE listener.
AbstractLoadableFile
  
onHttpStatus(evt:HTTPStatusEvent):void
HTTPStatusEvent.HTTP_STATUS listener.
AbstractLoadableFile
  
onInit(evt:Event):void
Event.INIT listener.
AbstractLoadableFile
  
onIOError(evt:IOErrorEvent):void
IOErrorEvent listener.
AbstractLoadableFile
  
onOpen(evt:Event):void
Event.OPEN listener.
AbstractLoadableFile
  
onProgress(evt:ProgressEvent):void
ProgressEvent.PROGRESS listener.
AbstractLoadableFile
  
onSecurityError(evt:SecurityErrorEvent):void
SecurityErrorEvent listener.
AbstractLoadableFile
  
processLoading(request:URLRequest):void
Tell the ILoadableFile to start the loading process.
AbstractLoadableFile
  
registerTo(dispatcher:IEventDispatcher):void
Register the events of the AbstractLoadableFile.
AbstractLoadableFile
  
unregisterFrom(dispatcher:IEventDispatcher):void
Unregister the events of the AbstractLoadableFile.
AbstractLoadableFile
Events
 Event Summary Defined By
  Dispatched when the download operation stops.AbstractLoadableFile
  Dispatched after all the received data is received.AbstractLoadableFile
 InheritedDispatched after an event is dispatched.GlobalEventDispatcher
 InheritedDispatched before an event is dispatched.GlobalEventDispatcher
  Dispatched when the http headers are received.AbstractLoadableFile
  Dispatched when the content of the loadManagerObject is displayed.AbstractLoadableFile
  Dispatched if a call to start() results in a fatal error that terminates the download.AbstractLoadableFile
  Dispatched when the download operation commences following a call to the ILoadManager.load() method.AbstractLoadableFile
  Dispatched when data is received as the download operation progresses.AbstractLoadableFile
  Dispatched if a call to start() attempts to load data from a server outside the security sandbox.AbstractLoadableFile
  Dispatched when the load couldn't start.AbstractLoadableFile
Public Constants
 ConstantDefined By
  NO_CACHE_VARIABLE_NAME : String = noCache
[static] Name of the 'no cache' variable.
AbstractLoadableFile
Property Detail
bytesLoadedproperty
bytesLoaded:uint  [read-only]

Defines the bytes that have been loaded.


Implementation
    public function get bytesLoaded():uint
bytesTotalproperty 
bytesTotal:uint  [read-only]

Defines the total bytes to load.


Implementation
    public function get bytesTotal():uint
bytesTotalRetrievedproperty 
bytesTotalRetrieved:Boolean  [read-only]

Defines if the bytesTotal have been retrieved.


Implementation
    public function get bytesTotalRetrieved():Boolean
closeEventproperty 
closeEvent:Event  [read-only]

Defines the event that happend to close the file (Event.CLOSE, Event.COMPLETE, ...).


Implementation
    public function get closeEvent():Event
fixedRequestproperty 
fixedRequest:URLRequest  [read-only]

Defines the URLRequest that has been loaded by the ILoadableFile.


Implementation
    public function get fixedRequest():URLRequest
loadedproperty 
loaded:Boolean  [read-only]

Defines if the ILoadManager operation is complete. This value is true only if the data has been successfully loaded.


Implementation
    public function get loaded():Boolean
loadManagerObjectproperty 
loadManagerObject:Object  [read-only]

Defines the load manager object.


Implementation
    public function get loadManagerObject():Object
netStateproperty 
netState:String  [read-write]

Defines the NetState value. The value available can be retrieved from the NetState class.


Implementation
    public function get netState():String
    public function set netState(value:String):void

See also

propertiesproperty 
properties:IProperties  [read-only]

Defines the properties stored in the ILoadableFile.


Implementation
    public function get properties():IProperties
stateIdleproperty 
stateIdle:Boolean  [read-only]

Defines if the AbstractLoadableFile is idle.


Implementation
    public function get stateIdle():Boolean
stateLoadingproperty 
stateLoading:Boolean  [read-only]

Defines if the AbstractLoadableFile is loading.


Implementation
    public function get stateLoading():Boolean
urlRequestproperty 
urlRequest:URLRequest  [read-write]

Defines the URLRequest object that specify the URL to load. If the AbstractLoadableFile is destroyed, it will keep a URLRequest object with the URL.


Implementation
    public function get urlRequest():URLRequest
    public function set urlRequest(value:URLRequest):void
urlVariablesproperty 
urlVariables:IMap  [read-write]

Defines the variables key/values to be replaced in the url before the loading is launched.


Implementation
    public function get urlVariables():IMap
    public function set urlVariables(value:IMap):void
useCacheproperty 
useCache:Boolean  [read-write]

Defines if the ILoadManager can use the cache or not.


Implementation
    public function get useCache():Boolean
    public function set useCache(value:Boolean):void

See also

virtualBytesTotalproperty 
virtualBytesTotal:uint  [read-write]

Defines the virtual total bytes. This value represents an approximation of the total bytes. This value should be greater than the real amount of bytes of the loadable file.


Implementation
    public function get virtualBytesTotal():uint
    public function set virtualBytesTotal(value:uint):void
Constructor Detail
AbstractLoadableFile()Constructor
public function AbstractLoadableFile(loadManagerObject:Object)

Creates a new AbstractLoadableFile object. This method throws an error if it is directly called or if a sub-class doesn't implement the ILoadableFile interface.

Parameters
loadManagerObject:Object — The loadManagerObject.

Throws
flash.errors:IllegalOperationError If — the sub-class doesn't implement ILoadableFile.
Method Detail
checkData()method
protected function checkData():void

Checks if data has been loaded and is available to be retrieved. If not, then an Error will be thrown. This method is useful to get direct information about why the data couldn't be retrieved.


Throws
ch.capi.errors:DataError If — the data are not loaded.
checkDestroyed()method 
protected function checkDestroyed():void

Checks if the current ILoadableFile has been destroyed and if so, throws an IllegalOperationError.


Throws
flash.errors:IllegalOperationError If — the AbstractLoadableFile has been destroyed.
destroy()method 
public function destroy():void

Destroys this ILoadableFile. This method causes to set the loadManagerObject value to null and releases all other references to the content loaded contained in the current ILoadableFile. This method also resets all the variables of the ILoadableFile. It just keeps a URLRequest with the specified file URL. After calling this method, no more operation is available on the ILoadableFile instance.

getUpdatedUrlRequest()method 
protected function getUpdatedUrlRequest():URLRequest

Creates a clone of the current URLRequest and put the variables values in its data. If there is some variables in the data object, they will be also replaced.

Returns
URLRequest — The new URLRequest.
getURLRequest()method 
protected function getURLRequest():URLRequest

Retrieves the URLRequest that is created depending of the useCache property value. The creation of the URLRequest is based on the netState. If the isOnline() method returns false or the useCache property value is true, then the current urlRequest is returned. Else a new URLRequest is created, cloning the data and adding a no cache variable.

Returns
URLRequest — The URLRequest.

Throws
flash.errors:IllegalOperationError If — the AbstractLoadableFile has been destroyed.

See also

invalidateFixedRequest()method 
public function invalidateFixedRequest():void

Invalidate the current fixedRequest. It means that the next time the start() method will be launched, the ILoadableFile will relaunch the loading of the data, without taking care of the cache.

See also

isDestroyed()method 
public function isDestroyed():Boolean

Retrieves if this ILoadableFile has been destroyed. If this method returns true, then no more operation is available on the ILoadableFile.

Returns
Booleantrue if the file has been destroyed.
isInstanceOf()method 
protected function isInstanceOf(source:String, superClasses:Array, appDomain:ApplicationDomain = null):Boolean

Checks if the specified source class is a child of one of the specified super classes.

Parameters

source:String — The source class.
 
superClasses:Array — An Array of String describing a list of classes.
 
appDomain:ApplicationDomain (default = null) — The ApplicationDomain to retrieve the classes.

Returns
Booleantrue if the source class extends one of the super classes.
isInstanceOfClass()method 
protected function isInstanceOfClass(source:String, superClass:String, appDomain:ApplicationDomain = null):Boolean

Checks if the specified source class is a child of the specified super class.

Parameters

source:String — The source class (child).
 
superClass:String — The super class.
 
appDomain:ApplicationDomain (default = null) — The ApplicationDomain to retrieve the classe.

Returns
Booleantrue if the source class extends the super class.

See also

isOnline()method 
public function isOnline():Boolean

Retrieves if the current AbstractLoadableFile is online or not. If the current netState value is NetState.DYNAMIC, then the online state is retrieved from the specified url. If the url is relative (no protocol specified), then the online state is retrieved from the current security sandbox.

Returns
Booleantrue if the AbstractLoadableFile is online.

Throws
flash.errors:IllegalOperationError If — the AbstractLoadableFile has been destroyed.

See also

netState
Security.sandboxType
onComplete()method 
protected function onComplete(evt:Event):void

Event.COMPLETE listener.

Parameters

evt:Event — The event object.

onHttpStatus()method 
protected function onHttpStatus(evt:HTTPStatusEvent):void

HTTPStatusEvent.HTTP_STATUS listener.

Parameters

evt:HTTPStatusEvent — The event object.

onInit()method 
protected function onInit(evt:Event):void

Event.INIT listener. This method retrieves the root DisplayObject associated to the LoaderInfo and then initializes the content.

Parameters

evt:Event — The event object.


Throws
ArgumentError If — the Event target is not a LoaderInfo instance.
onIOError()method 
protected function onIOError(evt:IOErrorEvent):void

IOErrorEvent listener.

Parameters

evt:IOErrorEvent — The event object.

onOpen()method 
protected function onOpen(evt:Event):void

Event.OPEN listener.

Parameters

evt:Event — The event object.

onProgress()method 
protected function onProgress(evt:ProgressEvent):void

ProgressEvent.PROGRESS listener.

Parameters

evt:ProgressEvent — The event object.

onSecurityError()method 
protected function onSecurityError(evt:SecurityErrorEvent):void

SecurityErrorEvent listener.

Parameters

evt:SecurityErrorEvent — The event object.

prepareFixedRequest()method 
public function prepareFixedRequest():void

Tells the ILoadableFile to update the fixedRequest value that will be used to load the file. By default, this method is automatically called when the start() method is executed and the fixedRequest hasn't been updated.


Throws
flash.errors:IllegalOperationError If — the AbstractLoadableFile has been destroyed.
processLoading()method 
protected function processLoading(request:URLRequest):void

Tell the ILoadableFile to start the loading process. This method is supposed to be overriden by the sub-classes. It always throws an IllegalOperationError.

Parameters

request:URLRequest


Throws
flash.errors:IllegalOperationError Always — if not overriden.
registerTo()method 
protected function registerTo(dispatcher:IEventDispatcher):void

Register the events of the AbstractLoadableFile.

Parameters

dispatcher:IEventDispatcher — The IEventDispatcher of the events.

See also

start()method 
public final function start():Boolean

Set the state as loading. This method also update the fixedRequest if it hasn't been done before. In any cases, the fixedRequest is invalidated right after the loading is started (just to ensure that the fixedRequest will be update the next time the start() method is called).

Returns
Booleantrue if the loading has been started, false otherwise.

Throws
flash.errors:IllegalOperationError If — the AbstractLoadableFile has been destroyed.
 
flash.errors:IllegalOperationError If — the AbstractLoadableFile is already loading.
stop()method 
public final function stop():void

Set the state as idle.


Throws
flash.errors:IllegalOperationError If — the AbstractLoadableFile has been destroyed.
 
flash.errors:IllegalOperationError If — the ILoadManager is not loading.
toString()method 
override public function toString():String

Get the URL of the AbstractLoadableFile.

Returns
String — The url or null if the urlRequest is not defined.
unregisterFrom()method 
protected function unregisterFrom(dispatcher:IEventDispatcher):void

Unregister the events of the AbstractLoadableFile.

Parameters

dispatcher:IEventDispatcher — The IEventDispatcher of the events.

See also

Event Detail
close Event
Event Object Type: flash.events.Event
Event.type property = flash.events.Event.CLOSE

Dispatched when the download operation stops. This is following a call to the ILoadManager.stop() method.

complete Event  
Event Object Type: flash.events.Event
Event.type property = flash.events.Event.COMPLETE

Dispatched after all the received data is received.

httpStatus Event  
Event Object Type: flash.events.HTTPStatusEvent
HTTPStatusEvent.type property = flash.events.HTTPStatusEvent.HTTP_STATUS

Dispatched when the http headers are received. This event isn't sent by the all the load manager objects.

init Event  
Event Object Type: flash.events.Event
Event.type property = flash.events.Event.INIT

Dispatched when the content of the loadManagerObject is displayed. This event is only dispatched if the type of ILoadableFile is LoadableFileType.SWF or when the data of a binary URLLoaderFile is retrieved as DataType.LOADER.

ioError Event  
Event Object Type: flash.events.IOErrorEvent
IOErrorEvent.type property = flash.events.IOErrorEvent.IO_ERROR

Dispatched if a call to start() results in a fatal error that terminates the download.

open Event  
Event Object Type: flash.events.Event
Event.type property = flash.events.Event.OPEN

Dispatched when the download operation commences following a call to the ILoadManager.load() method.

progress Event  
Event Object Type: flash.events.ProgressEvent
ProgressEvent.type property = flash.events.ProgressEvent.PROGRESS

Dispatched when data is received as the download operation progresses.

securityError Event  
Event Object Type: flash.events.SecurityErrorEvent
SecurityErrorEvent.type property = flash.events.SecurityErrorEvent.SECURITY_ERROR

Dispatched if a call to start() attempts to load data from a server outside the security sandbox.

startFailed Event  
Event Object Type: ch.capi.events.LoadStartErrorEvent
LoadStartErrorEvent.type property = ch.capi.events.LoadStartErrorEvent.START_FAILED

Dispatched when the load couldn't start. That means that an error has occured during the start() method and an Error has been thrown.

Defines the 'startFailed' error event.
Constant Detail
NO_CACHE_VARIABLE_NAMEConstant
public static const NO_CACHE_VARIABLE_NAME:String = noCache

Name of the 'no cache' variable.