Chapter 8. Interfaces

 <  Day Day Up  >  

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 ActionScript 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, so lets dive right into an example.

 <  Day Day Up  >  


Essential ActionScript 2.0
Essential ActionScript 2.0
ISBN: 0596006527
EAN: 2147483647
Year: 2004
Pages: 177
Authors: Colin Moock

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net