MACROMEDIA FLASH MX 2004-USING ACTIONSCRIPT IN FLASH Use Manual page 262

Using actionscript in flash
Hide thumbs Also See for FLASH MX 2004-USING ACTIONSCRIPT IN FLASH:
Table of Contents

Advertisement

For example, the following code declares an interface named MyInterface that contains two
methods,
method_1()
specifies a return type of
, has a single parameter of type String, and specifies a return type of Boolean.
method_2()
interface MyInterface {
function method_1():Void;
function method_2(param:String):Boolean;
}
Interfaces cannot contain any variable declarations or assignments. Functions declared in an
interface cannot contain curly braces. For example, the following interface won't compile.
interface BadInterface{
// Compiler error. Variable declarations not allowed in interfaces.
var illegalVar;
// Compiler error. Function bodies not allowed in interfaces.
function illegalMethod(){
}
}
You can also use the
interface iA extends interface iB {}
The rules for naming interfaces and storing them in packages are the same as those for classes; see
"Creating and using classes" on page 254
Interfaces as data types
Like a class, an interface defines a new data type. Any class that implements an interface can be
considered to be of the type defined by the interface. This is useful for determining if a given
object implements a given interface. For example, consider the following interface:
interface Movable {
function moveUp():Void;
function moveDown():Void;
}
Now consider the class Box, which implements the Movable interface.
class Box implements Movable {
var xpos:Number;
var ypos:Number;
function moveUp():Void {
trace("moving up");
// method definition
}
function moveDown():Void {
trace("moving down");
// method definition
}
}
262
Chapter 10: Creating Custom Classes with ActionScript 2.0
and
. The first method,
method_2()
(meaning it does not return a value). The second method,
Void
keyword to create subclasses of an interface:
extends
and
method_1()
"Using packages" on page
, has no parameters and
260.

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-USING ACTIONSCRIPT IN FLASH and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Flash mx 2004 - actionscript

Table of Contents