MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 159

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

This code outputs the following in the Output panel:
three
two
one
For more information on objects and properties, see
You cannot iterate through the properties of an object if it is an instance of a custom
class, unless the class is a dynamic class. Even with instances of dynamic classes, you
are able to iterate only through properties that are added dynamically.
The curly braces (
statement are not necessary if only one statement executes.
for..in
The following example uses
To create a for loop:
1.
Select File > New and then select Flash Document.
2.
Select Frame 1 of the Timeline, and then type the following ActionScript in the
Actions panel:
var myObj:Object = {name:"Tara", age:27, city:"San Francisco"};
var i:String;
for (i in myObj) {
trace("myObj." + i + " = " + myObj[i]);
}
3.
Select Control > Test Movie to test the code in Flash Player.
When you test the SWF file, you should see the following text in the Output panel:
myObj.name = Tara
myObj.age = 27
myObj.city = San Francisco
If you write a
for..in
not available within the loop, but static members are. However, if you write a
a FLA file for an instance of the class, instance members are available but static members are
not. For more information on writing class files, see
more information, see the
) used to enclose the block of statements to be executed by the
{}
to iterate over the properties of an object:
for..in
loop in a class file (an external ActionScript file), instance members are
for..in statement
"Object data type" on page
Chapter 7, "Classes," on page
in the ActionScript 2.0 Language Reference.
78.
loop in
for..in
225. For
About statements
159

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents