EasyManua.ls Logo

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT - Page 384

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT
816 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
384 Chapter 12: ActionScript Dictionary
The following is an example of using for to perform the same action repeatedly. In the following
code, the
for loop adds the numbers from 1 to 100:
var sum = 0;
for (var i=1; i<=100; i++) {
sum = sum + i;
}
See also
++ (increment)
, –– (decrement), for..in, var
for..in
Availability
Flash Player 5.
Usage
for(variableIterant in object){
statement(s);
}
Parameters
variableIterant
The name of a variable to act as the iterant, referencing each property of an
object or element in an array.
object The name of an object to be repeated.
statement(s) An instruction to execute for each iteration.
Returns
Nothing.
Description
Statement; loops through the properties of an object or element in an array, and executes the
statement for each property of an object.
Some properties cannot be enumerated by the
for or for..in actions. For example, the built-in
methods of the Array class (such as
Array.sort() and Array.reverse()) are not included in
the enumeration of an Array object, and movie clip properties, such as _x and _y, are not
enumerated. In external class files, instance members are not enumerable; only dynamic and static
members are enumerable.
The
for..in statement iterates over properties of objects in the iterated objects prototype chain.
If the child’s prototype is parent, iterating over the properties of the child with for..in, will also
iterate over the properties of
parent.
The
for..in action enumerates all objects in the prototype chain of an object. Properties of the
object are enumerated first, then properties of its immediate prototype, then properties of the
prototypes prototype, and so on. The
for..in action does not enumerate the same property
name twice. If the object child has prototype parent and both contain the property prop, the
for..in action called on child enumerates prop from child but ignores the one in parent.

Table of Contents

Related product manuals