313
9
CHAPTER 9
Interfaces
In object-oriented programming (OOP), an interface is a document that lets you declare (but
not define) the methods that must appear within a class. When you work in teams of
developers, or build larger applications in Flash, interfaces can be very beneficial during
development. Interfaces allow developers to easily identify the base methods in ActionScript
classes. These methods must be implemented when developers use each interface.
This chapter walks you through a few sample interfaces, and by the end of the chapter you are
able to build your own interface files. If you are not familiar with building classes, make sure
that you read
Chapter 7, “Classes,”
before you try the tutorials and examples in this chapter.
For more information on working with interfaces, see the following topics:
About interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
Creating interfaces as data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318
Understanding inheritance and interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
Example: Using interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321
Example: Creating a complex interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .323
About interfaces
In object-oriented programming, interfaces are like classes whose methods are not
implemented (defined)—that is, they otherwise don’t “do” anything. Therefore, an interface
consists of “empty” methods. Another class can then implement the methods declared by the
interface. In ActionScript, the distinction between interface and object is only for compile-
time error checking and language rule enforcement.
Summary of Contents for FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Page 1: ...Learning ActionScript 2 0 in Flash...
Page 8: ...8 Contents...
Page 18: ...18 Introduction...
Page 30: ...30 What s New in Flash 8 ActionScript...
Page 66: ...66 Writing and Editing ActionScript 2 0...
Page 328: ...328 Interfaces...
Page 350: ...350 Handling Events...
Page 590: ...590 Creating Interaction with ActionScript...
Page 710: ...710 Understanding Security...
Page 730: ...730 Debugging Applications...
Page 780: ...780 Deprecated Flash 4 operators...
Page 830: ...830 Index...