
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
224
Chapter 8
CHAPTER 8
Interfaces
An interface is an ActionScript 2.0 language construct used to define a new datatype,
much as a class defines a datatype. However, whereas a class both defines a datatype
and provides the implementation for it, an interface defines a datatype in abstract
terms only; an interface provides no implementation for the datatype. That is, a class
doesn’t just declare a bunch of methods and properties, it also supplies concrete
behavior—the method bodies and property values that make the class actually do
something. An interface, instead of providing its own implementation, is adopted by
one or more classes that agree to provide the implementation. A class that provides
an implementation for an interface belongs both to its own datatype and to the
datatype defined by the interface. As a member of multiple datatypes, the class can
then play multiple roles in an application.
Don’t confuse the term interface, as discussed in this chapter, with
other uses of the word. In this chapter, “interface” refers to an Action-
Script 2.0 language construct, not a graphical user interface (GUI) or
the public API of a class, sometimes also called an interface in general
OOP theory.
Unless you’re familiar with interfaces already, theoretical descriptions of them can be
hard to follow, ...