Basic
A class is a template from which objects
are created. It defines the way an object
works and is used.
A class is a blueprint of how an object
is made up and how it should act.
Intermediate
Advanced
A Class is a defined data type, an aggregate
of named data elements an sd a set of operations
to manipulate that data.
A class can contain primitive data types
and referenced data types and a method by
which to manipulate the data in these data
types to create an new processed data type.
constructors are
used to create and use instances of a
class. (analogous to declaring a variable)
Constructors are used to build instances
of classes from the detailed code that defines
the exact methods and operations and actions
of a class. For example to use an array object
it must first be constructed using the array
constructor.
var myArray:Array = newArray();
The constructor has now created an object
that behaved as defined by the pre made array
class in flash. The object that has been
created can do everything that an array
is defined to do such as stores independent
pieces of data in an organized series of
compartments.
the new array called "myArray" can
now be used in a program by calling the object
e.g.myArray()........
Some
classes called top level classes do not need
a constructor as they do not store data that
is passed to them and so do not require multiple
instances. Top level classes
include Math, Mouse and key. Each of
these classes do not require
To use a custom class you need to define
a class head and class body and save the
class in an seperate actionscript file
.as
Each class must have its own .as file and
be stored in the same directory as the
main document files.
The class head
class
ClassName {
statements
methods
} |
Note: Conventionally
class names begin with a capital
letter.