|Interface||public interface IResourceBundle|
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
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
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
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
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:
FileSystemBundle, which normally is the fallback in case other bundles fail to satisfy a request.
EmbeddedBundle, which may be used to map to embedded objects (e.g. via the
mechanism, or the Flash IDE's library).
Starts trying to load an object based on the given request and returns an instance that can be used to track progress.
Method to check if the bundle supports loading a resource of the given type.
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
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.