324
Interfaces
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
k()
and
n()
methods in the ClassB class.
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.
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...