Packageflash.utils
Classpublic dynamic class Dictionary
InheritanceDictionary Inheritance Object

Language version: ActionScript 3.0
Runtime version: 

The Dictionary class lets you create a dynamic collection of properties, which uses strict equality (===) for key comparison. When an object is used as a key, the object's identity is used to look up the object, and not the value returned from calling toString() on it.

The following statements show the relationship between a Dictionary object and a key object:


 var dict = new Dictionary();

 var obj = new Object();

 var key:Object = new Object();

 key.toString = function() { return "key" }

 
 dict[key] = "Letters";

 obj["key"] = "Letters";

 
 dict[key] == "Letters"; // true

 obj["key"] == "Letters"; // true

 obj[key] == "Letters"; // true because key == "key" is true b/c key.toString == "key"

 dict["key"] == "Letters"; // false because "key" === key is false

 delete dict[key]; //removes the key

 

See also

=== (strict equality)


Public Properties
 PropertyDefined by
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
Public Methods
 MethodDefined by
  
Dictionary(weakKeys:Boolean = false)
Creates a new Dictionary object.
Dictionary
 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
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
Constructor detail
Dictionary()constructor
public function Dictionary(weakKeys:Boolean = false)

Language version: ActionScript 3.0
Runtime version: 

Creates a new Dictionary object. To remove a key from a Dictionary object, use the delete operator.

Parameters
weakKeys:Boolean (default = false) — Instructs the Dictionary object to use "weak" references on object keys. If the only reference to an object is in the specified Dictionary object, the key is eligible for garbage collection and is removed from the table when the object is collected.