# Interfaces

Interfaces in object-oriented programming can be described as classes, but classes whose methods are not implemented. Another class can agrees to provide definitions for, or implement, the methods declared (but not defined) by the interface.

An interface can also be thought of as a "programming contract" that can be used to enforce relationships between otherwise unrelated classes. For example, say you are working with a team of programmers, each of whom is working on a different part (class) of the same application. While designing the application, you agree on a set of methods that the different classes will use to communicate. So you create an interface that declares these methods, their parameters and return types. Any class that implements this interface must provide definitions for those methods, otherwise a compiler error will result.

Yet another use of interfaces to provide a limited form of "multiple inheritance", which is not allowed in ActionScript 2. Multiple inheritance is when a class extends more than one class. For example, in C++ the Cat class could extend the Mammal class, as well as a Playful class, which has methods ChaseTail and EatCatNip. ActionScript 2, like Java, does not allow a class to directly extend multiple classes.

However, using interfaces you could create an Playful interface that declares the ChaseTail and EatCatNip methods. A Cat class, or any other class, could then implement this interface and provide definitions for those methods.

For details on see Runtime considerations of ActionScript 2.