224
Functions and Methods
When you use this ActionScript, you are calling the
eatCabbage()
method of the
EatingHabits class.
6.
After the previous line of ActionScript, add the following code:
function eatCarrots():Void {
trace("tastes good");
}
eatCarrots();
In this code, you write and call the
eatCarrots()
function.
7.
Select Control > Test Movie to test the SWF file.
Naming methods
You should use verbs to name methods, and words with mixed cases for concatenated words,
making sure that the first letter is lowercase. For example, you might name methods in the
following ways:
sing();
boogie();
singLoud();
danceFast();
You use verbs for most method names because methods perform an operation on an object. As
with variables, you cannot use special characters, and the method name cannot start with a
number. For more information, see
“Naming conventions” on page 732
.
NO
TE
When you use methods of any built-in class (in addition to the custom class you
wrote earlier in this procedure), you are using a
method
on a timeline.
Summary of Contents for FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Page 1: ...Learning ActionScript 2 0 in Flash...
Page 8: ...8 Contents...
Page 18: ...18 Introduction...
Page 30: ...30 What s New in Flash 8 ActionScript...
Page 66: ...66 Writing and Editing ActionScript 2 0...
Page 328: ...328 Interfaces...
Page 350: ...350 Handling Events...
Page 590: ...590 Creating Interaction with ActionScript...
Page 710: ...710 Understanding Security...
Page 730: ...730 Debugging Applications...
Page 780: ...780 Deprecated Flash 4 operators...
Page 830: ...830 Index...