EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 274

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 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...
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 cant 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 youre 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 codes
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.
NOTE
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.

Table of Contents

Related product manuals