Game Development Reference
In-Depth Information
As a standard naming convention, classes should start with a
capital letter and then use InterCaps, or
from then
on,denotingthestartofawordwithacapitalletter.CamelCase
makes names in code much easier to read
CamelCase
take, for example,
the longest class name currently used in the Flash CS5 code
base:
HTMLUncaughtScriptExceptionEvent
While this is something of an extreme example, note that it is
much easier to read than:
htmluncaughtscriptexceptionevent
Packages
A set of classes with categorically similar or related functionality
can be grouped together in packages. Classes within the same
package can reference each other without any special code,
whereas classes in different packages must import each other with
a line of code, similar to the following:
import flash.display.MovieClip;
Note that in this case, the MovieClip class is inside the display
package, which is part of the larger flash package. The standard
naming convention for packages is all lowercase letters, which
differentiates them from classes visually. Packages are represented
in the file system as a series of nested folders. In the previous
example, if the MovieClip class were not an included part of the
Flash Player, you could find the MovieClip.as file inside a folder
called display, inside another folder called flash.
Classes as Files
To create a class, you simply open Flash or a text editor like Flash-
Develop and create a basic framework. All AS3 classes must have
this minimal amount of code in order to function.
package flash.display {
public class MovieClip {
}
}
Note that the names in bold are the custom package and class
names of your choice. All classes need a class definition wrapped
by a package definition, placed in a folder structure that matches
the package hierarchy. However, this class won
'
tdoanything,so
next we
'
ll cover adding properties and methods.
Search Nedrilad ::




Custom Search