274
Classes
This previous code sets both methods (the ClassA constructor and the
doSomething()
method) as public, meaning that they can be accessed by external scripts. The static
_className
variable is set as private, meaning the variable can be accessed only from
within the class and not from external scripts.
3.
Modify the ClassB.as ActionScript file and add the same method and property access as the
ClassA class.
4.
Save both ActionScript files before you proceed.
An instance of ClassA or ClassB cannot access the private members. For example, the
following code, added to Frame 1 of the Timeline in a FLA file, would result in a compiler
error indicating that the method is private and can’t be accessed:
import com.macromedia.utils.ClassA;
var a:ClassA = new ClassA();
trace(a._className); // Error. The member is private and cannot be accessed.
Member access control is a compile-time-only feature; at runtime, Flash Player does not
distinguish between private or public members.
To continue writing your class file, see
“Documenting the classes” on page 274
.
Documenting the classes
Using comments in your classes and interfaces is an important part of documenting them for
other users. For example, you might want to distribute your class files into the Flash
community, or you might be working with a team of designers or developers who will use
your class files in their work or as part of a project you’re working on. Documentation helps
other users understand the purpose and origins of the class.
There are two kinds of comments in a typical class or interface file:
documentation comments
and
implementation comments
. You use documentation comments to describe the code’s
specifications, but not the implementation. You use implementation comments to comment
out code or to comment on the implementation of particular sections of code. The two kinds
of comments use slightly different delimiters. Documentation comments are delimited with
/**
and
*/
, and implementation comments are delimited with
/*
and
*/
.
Use documentation comments to describe interfaces, classes, methods, and constructors.
Include one documentation comment per class, interface, or member, and place it directly
before the declaration.
NOT
E
Documentation comments are not a language construct in ActionScript 2.0. However,
they are a common way of structuring comments in a class file that you can use in your
AS files.
Содержание 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...