MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 325

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

10.
In ClassC.as, type the following ActionScript code into the Script window:
// filename: ClassC.as
class ClassC implements InterfaceA {
public function k():Number {
return 25;
}
// **Error** The class must also implement method 'n' from interface
'InterfaceA'.
}
If you click the Check Syntax button for the ClassC class file, Flash displays an error
message in the Output panel that says the current class must implement the
defined in the InterfaceA interface. When you create classes that implement an interface,
it is important that you define methods for each entry in the interface.
11.
Create a new ActionScript document and save it as InterfaceB.as in the complexInterface
directory.
12.
In InterfaceB.as, type the following ActionScript code into the Script window:
// filename: InterfaceB.as
interface InterfaceB {
public function o():Void;
}
13.
Save your changes to the InterfaceB.as document, and then create a new ActionScript
document and save it in the complexInterface directory as ClassD.as.
This class implements both the InterfaceA interface and the InterfaceB interface you
created in earlier steps. The ClassD class must include method implementations for each
of the methods listed in each of the interface files.
14.
In ClassD.as, type the following ActionScript code into the Script window:
// filename: ClassD.as
class ClassD implements InterfaceA, InterfaceB {
public function k():Number {
return 15;
}
public function n(z:Number):Number {
return (z * z);
}
public function o():Void {
trace("o");
}
}
15.
Save your changes to the ClassD.as file, and then create a new Flash document and save it
as classdTest.fla.
This Flash document tests the ClassD class that you created previously.
Example: Creating a complex interface
method
n()
325

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents