Packageimpression.resolver
Classpublic class AssetResolver
InheritanceAssetResolver Inheritance flash.events.EventDispatcher

The AssetResolver class provides a common object for resolving media asset filenames to fully qualified URIs and it also provides a single location for loading and monitoring multiple files.



Public Properties
 PropertyDefined By
  path : String
The base URI for assets.
AssetResolver
  resolverInfo : ResolverInfo
[read-only] The ResolverInfo object for the resolver.
AssetResolver
Public Methods
 MethodDefined By
  
AssetResolver(path:String = null)
Creates a new instance of the AssetResolver class.
AssetResolver
  
beginOwnerTransaction(owner:*, clearHistory:Boolean = true):void
Places an owner into transaction mode.
AssetResolver
  
beginTransaction(clearHistory:Boolean = true):void
Places the resolver into transaction mode.
AssetResolver
  
Cancels a transaction started with the beginOwnerTransaction() method.
AssetResolver
  
Cancels a transaction started with the beginTransaction() method.
AssetResolver
  
closeAll():void
Closes all of the active items.
AssetResolver
  
closeAllOf(owner:* = null):void
Closes all of the active items for an owner.
AssetResolver
  
endOwnerTransaction(owner:*):void
Completes a transaction started with the beginOwnerTransaction() method.
AssetResolver
  
Completes a transaction started with the beginTransaction() method.
AssetResolver
  
Returns the ResolverInfo object for the owner.
AssetResolver
  
getURLRequest(item:*):URLRequest
Returns a URLRequest object for an item.
AssetResolver
  
load(item:*, loader:*, owner:* = null, context:* = null):void
Begins loading content into an object.
AssetResolver
  
Registers an object as an owner with this resolver.
AssetResolver
  
resolveFilename(item:*):String
Returns a fully qualified URI for an item.
AssetResolver
  
unregisterOwner(owner:*):void
Unregisters an object as an owner with this resolver.
AssetResolver
Property Detail
pathproperty
path:String

The base URI for assets.

The path property value is appended to the filename property of an AssetData object, resulting in a fully-qualified URI to use to load the asset.

If the path property value is set to null, the empty string ("") is used instead.


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

See also

resolverInfoproperty 
resolverInfo:ResolverInfo  [read-only]

The ResolverInfo object for the resolver.

The ResolverInfo object returned provides aggregate statistics and extended event information for all content objects that use this resolver.


Implementation
    public function get resolverInfo():ResolverInfo

See also

Constructor Detail
AssetResolver()Constructor
public function AssetResolver(path:String = null)

Creates a new instance of the AssetResolver class.

Parameters
path:String (default = null) — A String specifying the base URI for assets. The path is appended to the filename property of an AssetData object, resulting in a fully-qualified URI to use to load the asset.
Method Detail
beginOwnerTransaction()method
public function beginOwnerTransaction(owner:*, clearHistory:Boolean = true):void

Places an owner into transaction mode.

In transaction mode, the ResolverInfo object for the owner will dispatch two additional events, the ResolverEvent.BEGIN_TRANSACTION event and the ResolverEvent.END_TRANSACTION event. The ResolverEvent.BEGIN_TRANSACTION event will be dispatched when the first content object that has owner as its owner property value dispatches the ResolverEvent.BEGIN event. The ResolverEvent.END_TRANSACTION event will be dispatched when the last content object that has owner as its owner property value dispatches the ResolverEvent.END event, or the endOwnerTransaction() method is invoked, whichever occurs last.

If clearHistory is true, the aggregate statistics of the owner's ResolverInfo object are reset. If clearHistory is false, only the aggregate statistics of the active items of the owner's ResolverInfo object are reset.

Parameters

owner:* — The owner to place into transaction mode.
 
clearHistory:Boolean (default = true) — Specifies which aggregate statistics are reset.


Throws
ArgumentError — owner is not registered (ArgumentError).
 
ArgumentError — owner cannot be null (ArgumentError).

See also

beginTransaction()method 
public function beginTransaction(clearHistory:Boolean = true):void

Places the resolver into transaction mode.

In transaction mode, the ResolverInfo object for the current AssetResolver will dispatch two additional events, the ResolverEvent.BEGIN_TRANSACTION event and the ResolverEvent.END_TRANSACTION event. The ResolverEvent.BEGIN_TRANSACTION event will be dispatched when the first content object using this resolver dispatches the ResolverEvent.BEGIN event. The ResolverEvent.END_TRANSACTION event will be dispatched when the last content object using this resolver dispatches the ResolverEvent.END event, or the endTransaction() method is invoked, whichever occurs last.

If clearHistory is true, the aggregate statistics of the resolverss ResolverInfo object are reset. If clearHistory is false, only the aggregate statistics of the active items of the resolver's ResolverInfo object are reset.

Parameters

clearHistory:Boolean (default = true) — Specifies which aggregate statistics are reset.

See also

cancelOwnerTransaction()method 
public function cancelOwnerTransaction(owner:*):void

Cancels a transaction started with the beginOwnerTransaction() method.

If the transaction is cancelled, the ResolverInfo object will not dispatch the ResolverEvent.END_TRANSACTION event.

If a transaction is not active, invoking this method has no effect.

Parameters

owner:* — The owner to cancel transaction mode for.


Throws
ArgumentError — owner is not registered (ArgumentError).
 
ArgumentError — owner cannot be null (ArgumentError).

See also

cancelTransaction()method 
public function cancelTransaction():void

Cancels a transaction started with the beginTransaction() method.

If the transaction is cancelled, the ResolverInfo object will not dispatch the ResolverEvent.END_TRANSACTION event.

If a transaction is not active, invoking this method has no effect.

See also

closeAll()method 
public function closeAll():void

Closes all of the active items.

This method iterates through each object currently loading data that uses this resolver and invokes the close() method on the object.

See also

closeAllOf()method 
public function closeAllOf(owner:* = null):void

Closes all of the active items for an owner.

This method iterates through each object currently loading data that uses this resolver and, if the object's owner property matches the value of the owner parameter, invokes the close() method on the object.

If owner is null, active items whose owner property is null will be closed. If no active items can be found with a matching owner, invoking this method has no effect.

Parameters

owner:* (default = null) — The owner whose active items should be closed. This value may be null.

endOwnerTransaction()method 
public function endOwnerTransaction(owner:*):void

Completes a transaction started with the beginOwnerTransaction() method.

The endOwnerTransaction() method must be called so that the owner's ResolverInfo object can determine when to dispatch the ResolverEvent.END_TRANSACTION event.

If a transaction is not active, invoking this method has no effect.

Parameters

owner:* — The owner to complete transaction mode for.


Throws
ArgumentError — owner is not registered (ArgumentError).
 
ArgumentError — owner cannot be null (ArgumentError).

See also

endTransaction()method 
public function endTransaction():void

Completes a transaction started with the beginTransaction() method.

The endTransaction() method must be called so that the ResolverInfo object can determine when to dispatch the ResolverEvent.END_TRANSACTION event.

If a transaction is not active, invoking this method has no effect.

See also

getOwnerInfo()method 
public function getOwnerInfo(owner:*):ResolverInfo

Returns the ResolverInfo object for the owner. If owner has not been register with this resolver, it is registered.

If there is no ResolverInfo for the owner, a new ResolverInfo object will be created.

Parameters

owner:* — The owner of the return value.

Returns
ResolverInfo — A ResolverInfo object for owner.

Throws
ArgumentError — owner cannot be null (ArgumentError).
getURLRequest()method 
public function getURLRequest(item:*):URLRequest

Returns a URLRequest object for an item.

If item is null, null is returned. If item is a URLRequest, item is returned. For all other types, this method returns a new URLRequest object with a url parameter created by invoking resolveFilename() with item.

Parameters

item:* — Expression identifying the item to generate a URLRequest object for.

Returns
URLRequest — A URLRequest object for item.

See also

resolveFilename()
load()method 
public function load(item:*, loader:*, owner:* = null, context:* = null):void

Begins loading content into an object.

Normally, the owner and resolver properties of the LoaderEx, SoundEx, and URLLoaderEx properties are read-only after creation. Using this method (instead of the object's load() or loadAsset() methods) allows those properties to be changed without creating a new instance of the object.

Make sure that the object specified by the loader parameter is not active. Unexpected results can occur if the object's owner property is changed while the object is loading data.

Parameters

item:* — A reference to the content to load. The routine uses the getURLRequest() method, passing in item, to determine the actual content to load.
 
loader:* — The object to load content into. loader can be one of the following types:
  • LoaderEx, SoundEx, or URLLoaderEx. The method replaces the resolver property with a reference to the current object and the owner property with a reference to the owner parameter before loading begins.
  • Loader, Sound, or URLLoader. The method invokes the object's load method with the URLRequest created for item.

Other object types passed in as the loader parameter are ignored.

 
owner:* (default = null) — The new owner of the object. If owner is null, the object's current owner property is set to null.
 
context:* (default = null) — An optional SoundLoaderContext or LoaderContext object to pass to the loader object's load() method.

See also

registerOwner()method 
public function registerOwner(owner:*):ResolverInfo

Registers an object as an owner with this resolver.

Registering an owner allows developers to collect aggregate information and extended events for content objects that have a specific owner associated with them.

Parameters

owner:* — The owner to register.

Returns
ResolverInfo — A ResolverInfo object for owner.

Throws
ArgumentError — owner cannot be null (ArgumentError).
resolveFilename()method 
public function resolveFilename(item:*):String

Returns a fully qualified URI for an item.

If item is null, the empty string ("") is returned. If item is the empty string ("") or item is an object that, when cast to a String, resolves to the empty string, then the path property value is returned.

Parameters

item:* — Expression identifying the item to get the fully qualified URI of. item can be one of the following types:
  • URLRequest. The method calls resolveFilename with the url property value of item and returns the result.
  • AssetData. The method appends the AssetData object's filename property value to path and returns the result.
  • String. The method appends item to path and returns the result.
  • [other types]. The method appends the result of casting item to a String to path and returns the result.

Returns
String — The fully qualified URI for item.
unregisterOwner()method 
public function unregisterOwner(owner:*):void

Unregisters an object as an owner with this resolver.

If you maintain a reference to the ResolverInfo object for an unregistered owner, note that the ResolverInfo will not be updated with new aggregate statistics, nor will it dispatch any events.

Parameters

owner:* — The owner to unregister.


Throws
IllegalOperationError — cannot unregister owner while transaction is active (IllegalOperationError).