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

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

3.
In Interface.as, type the following ActionScript code into the Script window:
// filename: InterfaceA.as
interface InterfaceA {
public function k():Number;
public function n(z:Number):Number;
}
4.
Save the ActionScript document and then create a new ActionScript document named
ClassB.as and save it in the complexInterface directory.
ClassB.as implements the InterfaceA interface you created previously.
5.
In ClassB.as, type the following ActionScript code into the Script window:
// filename: ClassB.as
class ClassB implements InterfaceA {
public function k():Number {
return 25;
}
public function n(z:Number):Number {
return (z + 5);
}
}
6.
Save your changes to the ClassB.as document and then create a new Flash document and
save it as classbTest.fla in the complexInterface directory.
This class file tests the ClassB class you created previously.
7.
In classbTest.fla, type the following ActionScript code on Frame 1 of the Timeline:
// filename: classbTest.fla
import ClassB;
var myB:ClassB = new ClassB();
trace(myB.k()); // 25
trace(myB.n(7)); // 12
8.
Save your changes to the Flash document, and then select Control >Test Movie to test the
Flash document.
The Output panel displays two numbers, 25 and 12, which are the results of the
methods in the ClassB class.
n()
9.
Create a new ActionScript file and save it as ClassC.as in the complexInterface directory.
This class file implements the InterfaceA interface that you created in step 1.
324
Interfaces
and
k()

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