Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 128

Programming actionscript 3.0
Table of Contents

Advertisement

The Flash Player API follows a convention in which interface names begin with an uppercase
, but you can use any legal identifier as an interface name. Interface definitions are often
I
placed at the top level of a package. Interface definitions cannot be placed inside a class
definition or inside another interface definition.
Interfaces can extend one or more other interfaces. For example, the following interface,
IExample, extends the IExternalizable interface:
public interface IExample extends IExternalizable
{
function extra():void;
}
Any class that implements the IExample interface must include implementations not only for
the
method, but also for the
extra()
inherited from the IExternalizable interface.
Implementing an interface in a class
A class is the only ActionScript 3.0 language element that can implement an interface. Use the
keyword in a class declaration to implement one or more interfaces. The
implements
following example defines two interfaces, IAlpha and IBeta
implements them both:
interface IAlpha
{
function foo(str:String):String;
}
interface IBeta
{
function bar():void;
}
class Alpha implements IAlpha, IBeta
{
public function foo(param:String):String {}
public function bar():void {}
}
In a class that implements an interface, implemented methods must do the following:
Use the
access control identifier.
public
Use the same name as the interface method.
Have the same number of parameters, each with data types that match the interface
method parameter data types.
Use the same return type.
128
Object-Oriented Programming in ActionScript
and
writeExternal()
readExternal()
and a class, Alpha, that
,
methods

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents