Naming conventions
739
Naming functions and methods
Use the following guidelines when you name functions and methods in your code. For
information on writing functions and methods, see
Chapter 6, “Functions and Methods.”
■
Use descriptive names.
■
Use mixed case for concatenated words.
A good example would be
singLoud()
.
■
Start function and method names with a lowercase letter.
■
Describe what value is being returned in the function’s name.
For example, if you are returning the name of a song title, you might name the function
getCurrentSong()
.
■
Establish a naming standard for relating similar functions.
ActionScript 2.0 does not permit overloading. In the context of object-oriented
programming,
overloading
refers to the ability to make your functions behave differently
depending on which data types are passed into them.
■
Name methods as verbs.
You might concatenate the name, but it should contain a verb. You use verbs for most
methods because they perform an operation on an object.
Examples of method names include the following:
sing();
boogie();
singLoud();
danceFast();
Naming classes and objects
When you create a new class file, use the following guidelines when you name the class and
ActionScript file. For proper formatting, see the following examples of class names:
class Widget;
class PlasticWidget;
class StreamingVideo;
You might have public and private member variables in a class. The class can contain variables
that you do not want users to set or access directly. Make these variables private and allow
users to access the values only by using getter/setter methods.
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...