Datasheet

FIGURE 1.4
This UML diagram describes the relationship between an interface and an implementing class.
The interface doesn’t actually implement these methods. Its purpose is to define the method names
and structures. A class that implements the interface might look like this:
public class Dog implements Animal
{
public function sleep()
{ ... actual code to make the dog sleep ... }
public function bark()
{ ... actual code to make the dog bark ... }
}
Notice that a class that implements an interface can add other methods that the interface doesn’t
require. This approach is sometimes known as contract-based programming. The interface consti-
tutes a contract between the method that expects a particular set of methods and the object that
implements those methods.
Flex supports polymorphism both through the relationship between superclasses and subclasses
and through creation and implementation of interfaces in ActionScript 3.
Understanding the Flash Player
Flex applications are executed at runtime by the Flash Player or the Adobe Integrated Runtime. In
either case, they start as applications compiled to the .swf file format.
When you deploy a Flex application through the Web, it’s downloaded from a Web server at run-
time as a result of a request from a Web browser. The browser starts the Flash Player, which in turn
runs the application.
<<interface>>
Animal
+ move()
+ eat()
+ sleep()
+ move()
+ eat()
+ sleep()
Dog
15
About Flex 3
1
06_287644-ch01.qxp 6/23/08 11:28 PM Page 15