MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 229

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

Because these three class files are related, you might decide to put them in a package
(directory) called Shapes. In this case, the fully qualified class name would contain the
package path, as well as the simple class name. Package paths are denoted with dot (.) syntax,
where each dot indicates a subdirectory.
For example, if you placed each ActionScript file that defines a shape in the Shapes directory,
you would need to change the name of each class file to reflect the new location, as follows:
// In Shapes/Square.as:
class Shapes.Square {}
// In Shapes/Circle.as:
class Shapes.Circle {}
// In Shapes/Triangle.as:
class Shapes.Triangle {}
To reference a class that resides in a package directory, you can either specify its fully qualified
class name or import the package by using the
statement. For more information, see
import
"Working with packages" on page
230.
A comparison of classes and packages
In OOP, a class defines a category of object. Classes are essentially data types that you can
create if you want to define a new type of object in your application. A class describes the
properties (data) and behaviors (methods) for an object, much like an architectural blueprint
describes the characteristics of a building. The properties (variables defined within a class) and
methods of a class are collectively called the class's members. To use the properties and
methods defined by a class, you generally first create an instance of that class (except for
classes that have all static members (see
"About class (static) members" on page
298, such as
the top-level Math class, and
"Static methods and properties" on page
249). The relationship
between an instance and its class is similar to the relationship between a house and its
blueprints.
Packages in Flash are directories that contain one or more class files and reside in a designated
file path. You might place related custom class files within a single directory. For example, you
might have three related classes called SteelWidget, PlasticWidget, and WoodWidget that are
defined in SteelWidget.as, PlasticWidget.as, and WoodWidget.as. You would organize these
classes in the Widget package. For more information on packages, see
"Working with
packages" on page 230
and
"Creating and packaging your class files" on page
266.
About object-oriented programming and Flash
229

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents