Example: Creating A Complex Interface - MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

11.
Save your changes to the interface file, and then reopen the FlashPaper.as document.
12.
Click the Check Syntax button, and you see a new error message in the Output panel:
**Error** path\FlashPaper.as: Line 1: The class must implement method
'addComment' from interface 'IDocumentation'.
class FlashPaper implements IDocumentation {
Total ActionScript Errors: 1
You see the previous error because the FlashPaper.as class file no longer defines all the
classes that you outlined in the interface file. To fix this error message, you must either add
the
addComment()
the IDocumentation interface file.
13.
Add the following method in the FlashPaper class:
public function addComment(username:String, comment:String):Void {
/* Send parameters to server-side page, which inserts comment into
database. */
}
14.
Save the changes to FlashPaper.as and click the Check Syntax button and you should no
longer receive any errors.
In the previous section, you created a class-based on the IDocumentation interface file. In this
section you create a new class that also implements the IDocumentation interface, although it
adds some additional methods and properties.
This tutorial demonstrates the usefulness of using interfaces because if you want to create
another class that extends the IDocumentation interface, you can easily identify the methods
that are required within the new class.

Example: Creating a complex interface

The following example shows several ways to define and implement interfaces. In this tutorial
you learn how to create a simple interface file and how to write a class that implements
multiple interfaces, as well as how to have interfaces extend other interfaces to create more
complex data structures.
To create a complex interface:
1.
Create a new ActionScript document and save it as InterfaceA.as.
2.
Create a new folder called complexInterface and save InterfaceA.as to this directory.
You save all of the files you create for this tutorial in this directory.
Reported Errors: 1
method to the FlashPaper class or remove the method definition from
Example: Creating a complex interface
323

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