Pacotemx.resources
Classepublic class ResourceManager
HerançaResourceManager Inheritance EventDispatcher Inheritance Object
Implementa IResourceManager

This class provides an implementation of the IResourceManager interface. The IResourceManager and IResourceBundle interfaces work together to provide internationalization support for Flex applications.

A single instance of this class manages all localized resources for a Flex application.

Veja também

mx.resources.IResourceManager
mx.resources.IResourceBundle


Propriedades Públicas
 PropriedadeDefinido por
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  localeChain : Array
An Array of locale Strings, such as [ "en_US" ], which specifies one or more locales to be searched for resources.
ResourceManager
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
Métodos Públicos
 MétodoDefinido por
  
Constructor
ResourceManager
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event.
EventDispatcher
  
Adds the specified ResourceBundle to the ResourceManager so that its resources can be accessed by ResourceManager methods such as getString().
ResourceManager
 Inherited
Dispatches an event into the event flow.
EventDispatcher
  
ResourceManager
  
getBoolean(bundleName:String, resourceName:String, locale:String = null):Boolean
Gets the value of a specified resource as a Boolean.
ResourceManager
  
Returns an Array of Strings specifying the bundle names for all ResourceBundles which exist in the ResourceManager and which belong to the specified locale.
ResourceManager
  
getClass(bundleName:String, resourceName:String, locale:String = null):Classe
Gets the value of a specified resource as a Classe.
ResourceManager
  
[static] Gets the single instance of the ResourceManager class.
ResourceManager
  
getInt(bundleName:String, resourceName:String, locale:String = null):int
Gets the value of a specified resource as an int.
ResourceManager
  
Returns an Array of Strings specifying all locales for which ResourceBundles exist in the ResourceManager.
ResourceManager
  
getNumber(bundleName:String, resourceName:String, locale:String = null):Number
Gets the value of a specified resource as a Number.
ResourceManager
  
getObject(bundleName:String, resourceName:String, locale:String = null):*
Gets the value of a specified resource as an Object.
ResourceManager
  
Returns a ResourceBundle with the specified locale and bundleName which has been previously added to the ResourceManager with addResourceBundle().
ResourceManager
  
getString(bundleName:String, resourceName:String, parameters:Array = null, locale:String = null):String
Gets the value of a specified resource as a String, after substituting specified values for placeholders.
ResourceManager
  
getStringArray(bundleName:String, resourceName:String, locale:String = null):Array
Gets the value of a specified resource as an Array of Strings.
ResourceManager
  
getUint(bundleName:String, resourceName:String, locale:String = null):uint
Gets the value of a specified resource as a uint.
ResourceManager
 Inherited
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
EventDispatcher
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
  
loadResourceModule(url:String, update:Boolean = true, applicationDomain:ApplicationDomain = null, securityDomain:SecurityDomain = null):IEventDispatcher
Begins loading a resource module containing resource bundles.
ResourceManager
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object.
EventDispatcher
  
removeResourceBundle(locale:String, bundleName:String):void
Removes the specified ResourceBundle from the ResourceManager so that its resources can no longer be accessed by ResourceManager methods such as getString().
ResourceManager
  
Removes all ResourceBundles for the specified locale from the ResourceManager so that their resources can no longer be accessed by ResourceManager methods such as getString().
ResourceManager
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of the specified object.
Object
  
unloadResourceModule(url:String, update:Boolean = true):void
This method has not yet been implemented.
ResourceManager
  
Dispatches a "change" Event from the resource manager.
ResourceManager
 Inherited
Returns the primitive value of the specified object.
Object
 Inherited
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
EventDispatcher
Eventos
 Evento Descrição Definido por
 Inherited Dispatched when Flash Player or the and AIR application gains operating system focus and becomes active.EventDispatcher
   The CloseEvent.CHANGE constant defines the value of the type property of the event object for a close event.ResourceManager
 Inherited Dispatched when Flash Player loses operating system focus and is becoming inactive.EventDispatcher
Detalhes da propriedade
localeChainpropriedade
localeChain:Array  [read-write]

An Array of locale Strings, such as [ "en_US" ], which specifies one or more locales to be searched for resources.

When you call the ResourceManager methods getObject(), getString(), getStringArray(), getNumber(), getInt(), getUint(), getBoolean(), or getClass() to get the value of a resource, you specify a bundle name and a resource name, but not a locale. The ResourceManager starts with the first locale in the localeChain and looks for a ResourceBundle with the specified bundle name for that locale. If such a ResourceBundle exists, and the specified resource exists in it, then the value of that resource is returned. Otherwise, the ResourceManager proceeds on to the other locales in the localeChain.

This scheme makes it possible to have locales which do not necessarily contain a complete set of localized resources. For exemplo, if you are localizing your application for Indian English rather than U.S. English, you need only supply resources for the en_IN locale in which the Indian spelling or usage differs from that in the U.S., and then set the localeChain to [ "en_IN", "en_US" ].

Many framework classes assume that they can always obtain, from some locale, the resources that they expect, and they will throw Errors if they cannot do so. Therefore, you must ensure that the localeChain always contains a complete set of resources. Unless you have done a complete localization of all the framework's resources as well as your own application's resources, you can keep the "en_US" locale at the end of your localeChain to ensure this.

Setting this property causes the ResourceManager to dispatch a "change" Event.


Implementação
    public function get localeChain():Array
    public function set localeChain(value:Array):void
Detalhes do construtor
ResourceManager()Construtor
public function ResourceManager()

Constructor

Detalhes do método
addResourceBundle()método
public function addResourceBundle(resourceBundle:IResourceBundle):void

Adds the specified ResourceBundle to the ResourceManager so that its resources can be accessed by ResourceManager methods such as getString().

Parâmetros

resourceBundle:IResourceBundle — The resource bundle to be added.

findResourceBundleWithResource()método 
public function findResourceBundleWithResource(bundleName:String, resourceName:String):IResourceBundle

Parâmetros

bundleName:String
 
resourceName:String

Retorna
IResourceBundle
getBoolean()método 
public function getBoolean(bundleName:String, resourceName:String, locale:String = null):Boolean

Gets the value of a specified resource as a Boolean.

This method first calls getString() and converts the result to lowercase. It then returns true if the result was "true". and false otherwise.

If the specified resource is not found, this method returns false.

Parâmetros

bundleName:String — The name of a resource bundle.
 
resourceName:String — The name of a resource in the resource bundle.
 
locale:String (default = null) — A specific locale to be used for the lookup, or null to search all locales in the localeChain. This parameter is optional and defaults to null; you should seldom need to specify it.

Retorna
Boolean — The resource value, as a Boolean, or false if it is not found.
getBundleNamesForLocale()método 
public function getBundleNamesForLocale(locale:String):Array

Returns an Array of Strings specifying the bundle names for all ResourceBundles which exist in the ResourceManager and which belong to the specified locale.

The order of bundle names in this array is not specified.

Parâmetros

locale:String — A locale string such as "en_US".

Retorna
Array — An Array of bundle names.
getClass()método 
public function getClass(bundleName:String, resourceName:String, locale:String = null):Classe

Gets the value of a specified resource as a Classe.

This method calls getObject() and coerces it to type Classe using the as operator. The result will be null if the resource value was not a class reference. It is useful if you have written a lines such as

   IMAGE=Embed("image.jpg")
   BUTTON_SKIN=ClassReference("skins.ButtonSkin_en_US")
   

in a .properties file and want to obtain the Classe that the Embed() or ClassReference() directive produced.

If the specified resource is not found, this method returns null.

Parâmetros

bundleName:String — The name of a resource bundle.
 
resourceName:String — The name of a resource in the resource bundle.
 
locale:String (default = null) — A specific locale to be used for the lookup, or null to search all locales in the localeChain. This parameter is optional and defaults to null; you should seldom need to specify it.

Retorna
Classe — The resource value, as a Classe, or null if it is not found.
getInstance()método 
public static function getInstance():IResourceManager

Gets the single instance of the ResourceManager class. This object manages all localized resources for a Flex application.

Retorna
IResourceManager — An object implementing IResourceManager.
getInt()método 
public function getInt(bundleName:String, resourceName:String, locale:String = null):int

Gets the value of a specified resource as an int.

This method calls getObject() and casts the result to an int. It is useful if you have written a line such as

   MINIMUM=5
   

in a .properties file and want to obtain the value 5 rather than "5".

If the specified resource is not found, this method returns 0.

Parâmetros

bundleName:String — The name of a resource bundle.
 
resourceName:String — The name of a resource in the resource bundle.
 
locale:String (default = null) — A specific locale to be used for the lookup, or null to search all locales in the localeChain. This parameter is optional and defaults to null; you should seldom need to specify it.

Retorna
int — The resource value, as an int, or 0 if it is not found.
getLocales()método 
public function getLocales():Array

Returns an Array of Strings specifying all locales for which ResourceBundles exist in the ResourceManager.

The order of locales in this array is not specified.

Retorna
Array — An Array of locale Strings.
getNumber()método 
public function getNumber(bundleName:String, resourceName:String, locale:String = null):Number

Gets the value of a specified resource as a Number.

This method calls getObject() and casts the result to a Number. It is useful if you have written a line such as

   LONGITUDE=170.3
   

in a .properties file and want to obtain the value 170.3 rather than "170.3".

If the specified resource is not found, this method returns NaN.

Parâmetros

bundleName:String — The name of a resource bundle.
 
resourceName:String — The name of a resource in the resource bundle.
 
locale:String (default = null) — A specific locale to be used for the lookup, or null to search all locales in the localeChain. This parameter is optional and defaults to null; you should seldom need to specify it.

Retorna
Number — The resource value, as a Number, or NaN if it is not found.
getObject()método 
public function getObject(bundleName:String, resourceName:String, locale:String = null):*

Gets the value of a specified resource as an Object.

The value is returned exactly as it is stored in the content Object of the ResourceBundle, with no conversion. If the resource was compiled from a .properties files, the resource value in the content Object is always a String unless you used the Embed() or ClassReference() directive, in which case it is a Classe. Use the getString(), getStringArray(), getNumber(), getInt() getUint(), getBoolean(), and getClass() methods to convert the value to more specific types.

If the specified resource is not found, this method returns undefined.

Parâmetros

bundleName:String — The name of a resource bundle.
 
resourceName:String — The name of a resource in the resource bundle.
 
locale:String (default = null) — A specific locale to be used for the lookup, or null to search all locales in the localeChain. This parameter is optional and defaults to null; you should seldom need to specify it.

Retorna
* — The resource value, exactly as it is stored in the content Object, or undefined if the resource is not found.
getResourceBundle()método 
public function getResourceBundle(locale:String, bundleName:String):IResourceBundle

Returns a ResourceBundle with the specified locale and bundleName which has been previously added to the ResourceManager with addResourceBundle(). If no such ResourceBundle exists, this method returns null.

Parâmetros

locale:String — A locale string such as "en_US".
 
bundleName:String — A bundle name such as "MyResources".

Retorna
IResourceBundle — The ResourceBundle with the specified locale and bundleName if one exists; otherwise null.
getString()método 
public function getString(bundleName:String, resourceName:String, parameters:Array = null, locale:String = null):String

Gets the value of a specified resource as a String, after substituting specified values for placeholders.

This method calls getObject() and then casts the result to a String.

If a parameters Array is passed to this method, the parameters in it are converted to Strings and then substituted, in order, for the placeholders "{0}", "{1}", etc., in the string before it is returned.

If the specified resource is not found, this method returns null.

Parâmetros

bundleName:String — The name of a resource bundle.
 
resourceName:String — The name of a resource in the resource bundle.
 
parameters:Array (default = null) — An Array of parameters which are substituted for the placeholders. Each parameter is converted to a String with toString() before being substituted.
 
locale:String (default = null) — A specific locale to be used for the lookup, or null to search all locales in the localeChain. This parameter is optional and defaults to null; you should seldom need to specify it.

Retorna
String — The resource value, as a String, or null if it is not found.
getStringArray()método 
public function getStringArray(bundleName:String, resourceName:String, locale:String = null):Array

Gets the value of a specified resource as an Array of Strings.

This method assumes that the resource value is a String containing a comma-separated list of items. It calls getString(), splits the String into items at the commas, and trims whitespace before and after each item. It is useful if you have written a line such as

   COUNTRIES=India, China, Japan
   

in a .properties file and want to obtain the value [ "India", "China", "Japan" ] rather than "India, China, Japan".

If the specified resource is not found, this method returns null.

Parâmetros

bundleName:String — The name of a resource bundle.
 
resourceName:String — The name of a resource in the resource bundle.
 
locale:String (default = null) — A specific locale to be used for the lookup, or null to search all locales in the localeChain. This parameter is optional and defaults to null; you should seldom need to specify it.

Retorna
Array — The resource value, as an Array of Strings, or null if it is not found.
getUint()método 
public function getUint(bundleName:String, resourceName:String, locale:String = null):uint

Gets the value of a specified resource as a uint.

This method calls getObject() and casts the result to a uint. It is useful if you have written a line such as

   MINIMUM=5
   

in a .properties file and want to obtain the value 5 rather than "5".

If the specified resource is not found, this method returns 0.

Parâmetros

bundleName:String — The name of a resource bundle.
 
resourceName:String — The name of a resource in the resource bundle.
 
locale:String (default = null) — A specific locale to be used for the lookup, or null to search all locales in the localeChain. This parameter is optional and defaults to null; you should seldom need to specify it.

Retorna
uint — The resource value, as a uint, or 0 if it is not found.
loadResourceModule()método 
public function loadResourceModule(url:String, update:Boolean = true, applicationDomain:ApplicationDomain = null, securityDomain:SecurityDomain = null):IEventDispatcher

Begins loading a resource module containing resource bundles.

Each call to this method returns a new event-dispatching object that you can use to learn how the loading is progressing and whether it completes successfully or results in an error. This object dispatches ResourceEvent.PROGRESS, ResourceEvent.COMPLETE, and ResourceEvent.ERROR events.

When the module has been loaded, the resource bundles are added to the ResourceManager, but the localeChain is left unchanged. If the update parameter is true, the update() method will be called.

Parâmetros

url:String — The URL from which to load the resource module.
 
update:Boolean (default = true) — A flag indicating whether to call the update() method when the module has been loaded.
 
applicationDomain:ApplicationDomain (default = null) — The ApplicationDomain passed to the load() method of the IModuleInfo that loads the resource module. This parameter is optional and defaults to null.
 
securityDomain:SecurityDomain (default = null) — The SecurityDomain passed to the load() method of the IModuleInfo that loads the resource module. This parameter is optional and defaults to null.

Retorna
IEventDispatcher — An object associated with this particular load operation which dispatches ResourceEvent.PROGRESS, ResourceEvent.COMPLETE, and ResourceEvent.ERROR events.
removeResourceBundle()método 
public function removeResourceBundle(locale:String, bundleName:String):void

Removes the specified ResourceBundle from the ResourceManager so that its resources can no longer be accessed by ResourceManager methods such as getString().

Parâmetros

locale:String — A locale string such as "en_US".
 
bundleName:String — A bundle name such as "MyResources".

removeResourceBundlesForLocale()método 
public function removeResourceBundlesForLocale(locale:String):void

Removes all ResourceBundles for the specified locale from the ResourceManager so that their resources can no longer be accessed by ResourceManager methods such as getString().

Parâmetros

locale:String — A locale string such as "en_US".

unloadResourceModule()método 
public function unloadResourceModule(url:String, update:Boolean = true):void

This method has not yet been implemented.

Parâmetros

url:String
 
update:Boolean (default = true)

update()método 
public function update():void

Dispatches a "change" Event from the resource manager.

This will cause binding expressions to re-evaluate if they involve the ResourceManager methods getObject(), getString(), getStringArray(), getNumber(), getInt(), getUint(), getBoolean(), or getClass().

It will also cause the resourcesChanged() method of a UIComponent, Formatter, or Validator to execute. Many components implement this method to update their state based on the latest resources.

Detalhes do evento
change Evento
Event Object Type: flash.events.Event
Event.type property = mx.events.CloseEvent.CLOSE

The CloseEvent.CHANGE constant defines the value of the type property of the event object for a close event.

The properties of the event object have the following values:

PropriedadeValor
bubblesfalse
cancelablefalse
currentTargetThe Object that defines the event listener that handles the event. For exemplo, if you use myButton.addEventListener() to register an event listener, myButton is the value of the currentTarget.
detailFor controls with multiple buttons, detail identifies the button in the popped up control that was clicked.
targetThe Object that dispatched the event; it is not always the Object listening for the event. Use the currentTarget property to always access the Object listening for the event.