Packagede.mightypirates.utils.interfaces
Interfacepublic interface IResourceBundle
ImplementorsFileSystemBundle, ResourceBundle

Interface common to all resource bundles.

A resource bundle represents a data provider. It can be passed a URLRequest and should then try to satisfy the request. Essentially a resource bundle represents a transparent interface between an arbitrary data source and the requesting code. Data may for example be pulled from databases, web services, embedded classes and so on.

The request will normally be in a format as used for plain file system or web server queries, because the final fallback will always be a query to the resource bundle defined by the FileSystemBundle class.

A request for a supported datatype must be processed such that a IResourceLoader implementation is returned which eventually either dispatches a completion event (Event.COMPLETE) or an error event (ErrorEvent.ERROR). The actual implementation interals of the loader are up to the resource bundle.

When returned by the load function, the loader must be initialized such that the bundle, context, datatype and request properties are set. In case of a loaded IMAGE or SWF, the display property must be a valid DisplayObject, as well. This object must not be exchanged in the later lifetime of the loader.

When the load completes successfully, the loaded data must be available via the data property. In case of a loaded display object, i.e. if the data type is IMAGE or SWF, the result must be added to the container available through the display property.

When the load fails, no further action is required.

The completion or error events must never be fired immediately, so as to allow the calling resource provider a chance to register the handler functions.

When implementing a IResourceBundle, be aware that the loaders generated by it are not passed on to the requesting code scope, but only used internally in the ResourceProvider class. Due to lack of pointer (ha, ha) the loader implementation returned by the resource provider class is a wrapper class, which will be populated with the final data if a load succeeds, or used to forward an error event if it fails.

Existing implementations are:



Public Methods
 MethodDefined by
  
load(request:URLRequest, type:String, context:int, priority:*):IResourceLoader
Starts trying to load an object based on the given request and returns an instance that can be used to track progress.
IResourceBundle
  
supportsType(datatype:String):Boolean
Method to check if the bundle supports loading a resource of the given type.
IResourceBundle
Method detail
load()method
public function load(request:URLRequest, type:String, context:int, priority:*):IResourceLoader

Starts trying to load an object based on the given request and returns an instance that can be used to track progress.

Parameters
request:URLRequest — the requested URL to load.
 
type:String — the resource type.
 
context:int — optional loader context to use for some loaders.
 
priority:* — how urgent it is to process this request.

Returns
IResourceLoader — an object that can be used to track loading progress and access the loaded resource once complete.
supportsType()method 
public function supportsType(datatype:String):Boolean

Method to check if the bundle supports loading a resource of the given type. Bundles must never blindly return true here, but instead check the passed datatype against the constants defined in ResourceType, to avoid issues when new datatypes are added.

Parameters
datatype:String — the datatype that is currently being requested.

Returns
Boolean — whether this bundle supports loading data of that type.