EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 326

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
326 Interfaces
16. In classdTest.fla, add the following ActionScript code on Frame 1 of the Timeline:
// filename: classdTest.fla
import ClassD;
var myD:ClassD = new ClassD();
trace(myD.k()); // 15
trace(myD.n(7)); // 49
myD.o(); // o
17.
Save your changes to the classdTest.fla file and then select Control > Test Movie to test the
file.
The values 15 and 49 and the letter o should be displayed in the Output panel. These
values are the results of the
ClassD.k() method, ClassD.n(), and ClassD.o() methods,
respectively.
18. Create a new ActionScript document and save it as InterfaceC.as.
This interface extends the InterfaceA interface you created earlier, and it adds a new
method definition.
19. In InterfaceC.as, type the following ActionScript code into the Script window:
// filename: InterfaceC.as
interface InterfaceC extends InterfaceA {
public function p():Void;
}
20.
Save your changes to the ActionScript file and then create a new ActionScript file and save
it as ClassE.as in the complexInterface directory.
This class implements two interfaces, InterfaceB and InterfaceC.
21. In ClassE.as, type the following ActionScript code into the Script window:
// filename: ClassE.as
class ClassE implements InterfaceB, InterfaceC {
public function k():Number {
return 15;
}
public function n(z:Number):Number {
return (z + 5);
}
public function o():Void {
trace("o");
}
public function p():Void {
trace("p");
}
}
22.
Save your changes to the ActionScript document, and then create a new Flash document
and save it as classeTest.fla in the complexInterface directory.

Table of Contents

Related product manuals