Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 239

Programming actionscript 3.0
Table of Contents

Advertisement

Use the
loop for direct access to the object keys of a Dictionary object. You can also
for..in
access the values of the Dictionary object with the property access (
following code uses the previous example of the
through a Dictionary object with the
for (var key:Object in groupMap)
{
trace(key, groupMap[key]);
}
/* output:
[object Sprite] [object Object]
[object Sprite] [object Object]
[object Sprite] [object Object]
*/
Use the
for each..in
following code also uses the
object with the
for each..in
for each (var item:Object in groupMap)
{
trace(item);
}
/* output:
[object Object]
[object Object]
[object Object]
*/
Object keys and memory management
Flash Player uses a garbage collection system to recover memory that is no longer used. When
an object has no references pointing to it, the object becomes eligible for garbage collection,
and the memory is recovered the next time the garbage collection system executes. For
example, the following code creates a new object and assigns a reference to the object to the
variable
:
myObject
var myObject:Object = new Object();
As long as any reference to the object exists, the garbage collection system will not recover the
memory that the object occupies. If the value of
different object or is set to the value
becomes eligible for garbage collection, but only if there are no other references to the original
object.
for..in
loop for direct access to the values of a Dictionary object. The
dictionary to show how to iterate through a Dictionary
groupMap
loop:
, the memory occupied by the original object
null
[]
dictionary to show how to iterate
groupMap
loop:
is changed such that it points to a
myObject
) operator. The
Associative arrays
239

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents