ActionScript 3 Language Specification |
|||
| ActionScript 3.0 Language Specification > 10 Interfaces > 10.3 Interface example | |||
The following example shows how interfaces are defined and used.
interface T
{
function f()
}
interface U
{
function f()
function g()
}
interface V extends T,U
{
function h()
}
class A implements V
{
public function f() {} // implements {T,U}::f
public function g() {} // implements {U}::g
public function h() {} // implements {V}::h
}
var a : A = new A
var t : T = a
var u : U = a
var v : V = a
t.f() // {T}::f referenced, T::f matched
u.g() // {U}::g referenced, U::g matched
v.f() // {T,U,V}::f referenced, {T,U}::f matched
v.g() // {T,U,V}::g referenced, U::g matched
v.h() // {T,U,V}::h referenced, V::h matched
a.f() // {public,…}::f referenced, public::f matched
var o = a
o.f() // {public,…}::f referenced, public::f matched
A few highlights of this example:
public as an attribute to make the method implement all interface methods with a matching identifier.
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/specs/actionscript/3/as3_specification100.html