EasyManua.ls Logo

MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE - Function Statement

MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
1378 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...
212 ActionScript language elements
The following example uses for..in to iterate over the elements of an array:
var myArray:Array = new Array("one", "two", "three");
for (var index in myArray)
trace("myArray["+index+"] = " + myArray[index]);
// output:
myArray[2] = three
myArray[1] = two
myArray[0] = one
The following example uses the typeof operator with for..in to iterate over a particular
type of child:
for (var name in this) {
if (typeof (this[name]) == "movieclip") {
trace("I have a movie clip child named "+name);
}
}
The following example enumerates the children of a movie clip and sends each to Frame 2 in
itsrespective Timeline. The
RadioButtonGroup movie clip is a parent with three children:
_RedRadioButton_, _GreenRadioButton_,, and _BlueRadioButton_.
for (var name in RadioButtonGroup) { RadioButtonGroup[name].gotoAndStop(2);
}
function statement
Usage 1: (Declares a named function.)
function functionname([parameter0, parameter1,...parameterN]){
statement(s)
}
Usage 2: (Declares an anonymous function and returns a reference to it.)
function ([parameter0, parameter1,...parameterN]){
statement(s)
}
Comprises a set of statements that you define to perform a certain task. You can define a
function in one location and invoke, or call, it from different scripts in a SWF file. When you
define a function, you can also specify parameters for the function. Parameters are
placeholders for values on which the function operates. You can pass different parameters to a
function each time you call it so you can reuse a function in different situations.
Use the
return statement in a function's statement(s) to cause a function to generate, or
return, a value.
NOTE
If you have several movie clips, the output consists of the instance names of those clips.

Table of Contents

Related product manuals