Children include other functions, objects, and variables. The following example uses the
statement to print its results in the Output panel:
var myObject:Object = { name:'Joe', age:25, city:'San Francisco' };
for (propertyName in myObject) {
trace("myObject has the property: " + propertyName + ", with the value: " +
myObject[propertyName]);
}
This example produces the following results in the Output panel:
myObject has the property: name, with the value: Joe
myObject has the property: age, with the value: 25
myObject has the property: city, with the value: San Francisco
You might want your script to iterate over a particular type of child. You can do this using
with the
for..in
for (myname in my_object) {
if (typeof (my_object[myname]) == "anObject") {
trace("I have an object child named " + myname);
}
}
For more information on each action, see
Using built-in functions
A function is a block of ActionScript code that can be reused anywhere in a SWF file. If you pass
values as parameters to a function, the function will operate on those values. A function can also
return values.
Flash has built-in functions that let you access certain information and perform certain tasks, such
as getting the version number of Flash Player that is hosting the SWF file (
Functions that belong to an object are called methods. Functions that don't belong to an object are
called top-level functions.
Each function has individual characteristics, and some functions require you to pass certain
values. If you pass more parameters than the function requires, the extra values are ignored. If you
don't pass a required parameter, the empty parameters are assigned the
which can cause errors during runtime.
To call a function, simply use the function name and pass any required parameters:
isNaN(someVar);
getTimer();
eval("someVar");
For more information on each function, see its entry in
Elements," on page
Creating functions
You can define functions to execute a series of statements on passed values. Your functions can
also return values.
operator.
typeof
80.
,
,
while
do while
for
Chapter 5, "ActionScript Core Language
,
.
for..in
getVersion()
data type,
undefined
Creating functions
trace
).
41
Need help?
Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?
Questions and answers