User Guide
100 Chapter 3: Using Best Practices
The Flash MX 2004 object model does not support multiple inheritance; it supports only single
inheritance. Therefore, a class can come from a single parent class. This parent class can be either
a native Flash class or a user-defined class. Flash MX 2004 uses interfaces to provide additional
functionality, but only supports single inheritance. For information on interfaces, see “Interfaces”
on page 249. For information on implementing inheritance, see “Inheritance” on page 249. For
more information on Documentation comments, see “Using comments in classes” on page 102.
For information on import statements and class declarations, see “Creating a class file”
on page 251.
In ActionScript, the distinction between interface and object is only for the compile-time error
checking and language rule enforcement. An interface is not a class; however, this is not altogether
true in ActionScript at runtime. An interface is abstract, similar to the way it is in Java. However,
ActionScript interfaces do exist at runtime to allow type casting. An interface is not an object or a
class.
For more information, see the following topics:
• “Creating and organizing classes” on page 100
• “Programming classes” on page 102
• “Using prefixes in classes” on page 102
• “Using comments in classes” on page 102
• “Wrapping lines of code” on page 103
• “Using design patterns” on page 104
Creating and organizing classes
This section describes the structure of a class file. The following guidelines show how parts of a
class are ordered to increase efficiency and improve the readability in your code. For more
information on naming classes and parts of a class, see “General naming guidelines” on page 69.
The class file begins with documentation comments that include a general description of the
code, in addition to author information and version information.
Import statements follow the documentation comments. The first part of a package name is
written in lowercase letters and follows an established naming convention. For example, if you are
following the recommended naming guidelines, you might use the following statement:
import com.macromedia.Utils;
The next line of a class is a package statement, class declaration, or interface declaration, as the
following example shows:
class com.macromedia.users.UserClass{...}
Directly following the statement or declaration, include any necessary class or interface
implementation comments. Add information in this comment that is pertinent for the entire class
or interface.
Following the class or interface implementation comments, add all your static variables. Write the
public class variables first and follow them with private class variables.