03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Note: If you have several movie clips, the output consists of the instance names of those clips.<br />

The following example enumerates the children of a movie clip <strong>and</strong> sends each to Frame 2 in<br />

their respective Timelines. The RadioButtonGroup movie clip is a parent with several<br />

children, _RedRadioButton_, _GreenRadioButton_, <strong>and</strong> _BlueRadioButton_.<br />

for (var name in RadioButtonGroup) { RadioButtonGroup[name].gotoAndStop(2);<br />

}<br />

function statement<br />

Usage 1: (Declares a named function.)function functionname([parameter0,<br />

parameter1,...parameterN]){statement(s)}Usage 2: (Declares an anonymous function<br />

<strong>and</strong> returns a reference to it.)function ([parameter0, parameter1,...parameterN]){<br />

statement(s) }<br />

Comprises a set of statements that you define to perform a certain task. You can define a<br />

function in one location <strong>and</strong> invoke, or call, it from different scripts in a SWF file. When<br />

you define a function, you can also specify parameters for the function. Parameters are<br />

placeholders for values on which the function operates. You can pass different parameters to a<br />

function each time you call it so you can reuse a function in different situations.<br />

Use the return statement in a function's statement(s) to cause a function to generate, or<br />

return, a value.<br />

You can use this statement to define a function with the specified functionname,<br />

parameters, <strong>and</strong> statement(s). When a script calls a function, the statements in the<br />

function's definition are executed. Forward referencing is permitted; within the same script, a<br />

function may be declared after it is called. A function definition replaces any prior definition<br />

of the same function. You can use this syntax wherever a statement is permitted.<br />

You can also use this statement to create an anonymous function <strong>and</strong> return a reference to it.<br />

This syntax is used in expressions <strong>and</strong> is particularly useful for installing methods in objects.<br />

For additional functionality, you can use the arguments object in your function definition.<br />

Some common uses of the arguments object are creating a function that accepts a variable<br />

number of parameters <strong>and</strong> creating a recursive anonymous function.<br />

Returns<br />

String - Usage 1: The declaration form does not return anything. Usage 2: A reference to the<br />

anonymous function.<br />

Parameters<br />

functionname:String - The name of the declared function.<br />

184 ActionScript language elements

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!