The ResourceManager is a singleton class that facilitates the use of resource data associated with
the navigator. The resourceManager handles adding, loading, deleting, and
modification of resource data.
A ResourceManager static instance that can be shared by Flex components.
Implementation public static function get instance():ResourceManager
loadingCount
property
loadingCount:uint [read-only]
Language Version :
ActionScript 3.0
Product Version :
Portfolio 10.0
Runtime Versions :
Flash Player 10.1, AIR 2.0
Returns a count of the number of resource loads that are currently in the process
of being loaded.
This property can be used as the source for data binding.
Implementation public function get loadingCount():uint
purgeOnNeedsSave
property
public var purgeOnNeedsSave:Boolean = false
Language Version :
ActionScript 3.0
Product Version :
Portfolio 10.0
Runtime Versions :
Flash Player 10.1, AIR 2.0
A Boolean indicating whether or not resources should be auto-purged on a needsSave event.
swfFilter
property
swfFilter:FileFilter [read-only]
Language Version :
ActionScript 3.0
Product Version :
Portfolio 10.0
Runtime Versions :
Flash Player 10.1, AIR 2.0
Returns the filter for SWF files, if there is one.
Implementation public function get swfFilter():FileFilter
Constructor Detail
ResourceManager
()
Constructor
public function ResourceManager(target:IEventDispatcher = null)
Language Version :
ActionScript 3.0
Product Version :
Portfolio 10.0
Runtime Versions :
Flash Player 10.1, AIR 2.0
Constructor
Parameters
target:IEventDispatcher (default = null)
Method Detail
addResource
()
method
public function addResource(browseDialogTitle:String, browseDialogFilters:Array, relativeURL:String, response:Function = null):void
Language Version :
ActionScript 3.0
Product Version :
Portfolio 10.0
Runtime Versions :
Flash Player 10.1, AIR 2.0
Adds custom resources needed by the navigators. It brings up a file browsing dialog prompting the user
to select the needed file. Types that are not blacklisted will be added to the resources.
This operation is only allowed when the permission "Document"/"Modify" has been granted.
It accepts an optional callback function as an argument.
When a callback function is given, it is invoked to indicate the result of the operation.
The callback function receives a single argument, an Object, and has the following format:
function callback(response:Object):void
The response parameter contains properties that describe the response.
These include:
Property
Type
Value
'success'
Boolean
true if the operation succeeded; false otherwise
'relativeURL'
String
The path that identifes the resource.
This is the full relative path to the resource, and may differ from originalURL
if the caller passes an incomplete path, which is then completed by addResource().
Use this url to later read the resource.
'originalURL'
String
The path under which this resource was requested.
It will match relativeURL except in the case where
addResource() has completed an incomplete URL.
'error'
String
A non-human-readable String describing the error.
It is non-null only if success is false.
Parameters
browseDialogTitle:String — The title of the File browse dialog.
This is prefixed by a string to indicate to the user that
this is coming from the navigator.
browseDialogFilters:Array — An Array of FileFilter objects and will be used in the File browse dialog.
relativeURL:String — The path where the resource will be added. Must begin with "navigator/".
It must be a relative path, "/" separated, but with no leading "/".
If the URL does not have a file extension (that is, it does not contain a '.'),
then the file extension of the added file (if any) will be appended.
If the URL ends with "/", then the entire file name of the selected file
will be appended.
response:Function (default = null) — An optional notification function, as described above.
Throws
Error
— An Error is thrown if the
permission "Document"/"Modify" has not been granted.
public function deleteResource(relativeURL:String, response:Function = null):void
Language Version :
ActionScript 3.0
Product Version :
Portfolio 10.0
Runtime Versions :
Flash Player 10.1, AIR 2.0
Deletes the resource specified by relativeURL.
This operation is only allowed when the permission "Document"/"Modify" has been granted.
Accepts an optional callback function as an argument. When the callback function is non-null,
it is invoked to indicate the result of the operation. The callback function receives a single
argument, an Object, and has the following form:
function callback(response:Object):void
The response parameter contains properties that describe the response. These include:
Property
Type
Value
'success'
Boolean
true if the deletion succeeded, falseotherwise
'error'
String
A String describing the error. It is null if success is true
'relativeURL'
String
The value of the relativeURL> parameter in the function call.
Parameters
relativeURL:String
response:Function (default = null)
dereferenceResource
()
method
public function dereferenceResource(relativeURL:String, tryToDelete:Boolean = false):void
Language Version :
ActionScript 3.0
Product Version :
Portfolio 10.0
Runtime Versions :
Flash Player 10.1, AIR 2.0
Decrements by one the reference count for the specified relativeURL.
If the tryToDelete flag is set to true and the reference
count, after being decremented, is 0, the resource is also deleted.
Parameters
relativeURL:String
tryToDelete:Boolean (default = false)
getResource
()
method
public function getResource(relativeURL:String, binaryFormat:Boolean, completeListener:Function = null, ioErrorListener:Function = null, securityErrorListener:Function = null):NavURLLoader
Language Version :
ActionScript 3.0
Product Version :
Portfolio 10.0
Runtime Versions :
Flash Player 10.1, AIR 2.0
Returns a NavURLLoader suitable for loading the given resource URL,
and providing a binding to its resulting data. The loader begins loading immediately.
If event listeners are provided by the caller, then they will be invoked on the appropriate
events, and should not be removed by the caller.
public function purgeResources(purgeUnreferenced:Boolean = false):void
Language Version :
ActionScript 3.0
Product Version :
Portfolio 10.0
Runtime Versions :
Flash Player 10.1, AIR 2.0
Deletes resources from the collectiont that have been referenced,but whose refcounts have gone
to zero. If purgeUnreferenced is set to true, then resources that have not been referenced at all
will also be deleted.
Parameters
purgeUnreferenced:Boolean (default = false)
referenceResource
()
method
public function referenceResource(relativeURL:String):void
Language Version :
ActionScript 3.0
Product Version :
Portfolio 10.0
Runtime Versions :
Flash Player 10.1, AIR 2.0
Increments by one the reference count for the specified relativeURL
Parameters
relativeURL:String
showMissingResourcePopup
()
method
public function showMissingResourcePopup(entry:String, parent:DisplayObject):Boolean
Displays an alert as a popup with the given parent indicating the the given
resource entry cannot be found. Returns true if the popup is displayed;
false otherwise.
Parameters
entry:String
parent:DisplayObject
Returns
Boolean
touchResource
()
method
public function touchResource(relativeURL:String):void
Language Version :
ActionScript 3.0
Product Version :
Portfolio 10.0
Runtime Versions :
Flash Player 10.1, AIR 2.0
Set the reference count (initially to 0) for the relativeURL passed,
if the reference count has not already been set. This is functionally
equivalent to incrementing and decrementing the refcount.
A resource with a reference count of zero is more likely to be purged
by a call to purgeResources than a resource with no refcount.