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.
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...