共分5个文件:文件名分别是Iabstract.as AbstractDemo.as firstObj.as AbstractArea.as test.fla
----------------------------------------
Iabstract.as :
interface Iabstract{
function area()
}
-----
AbstractDemo.as :
class AbstractDemo implements Iabstract {
var x:Number;
var y:Number;
public function AbstractDemo(a, b) {
x = a;
y = b;
}
public function area() {
}
}
--------
firstObj.as :
class firstObj extends AbstractDemo {
public function firstObj(a, b) {
super(a, b);
}
public function area() {
return x*y;
}
}
--------
AbstractArea.as :
class AbstractArea {
var r:firstObj;
var a:AbstractDemo;
public function AbstractArea() {
r = new firstObj(10, 9);
a = r;
trace(a.area());
}
}
----------
test.fla:
myobj=new AbstractArea()
----------------------------------------
Iabstract.as :
interface Iabstract{
function area()
}
-----
AbstractDemo.as :
class AbstractDemo implements Iabstract {
var x:Number;
var y:Number;
public function AbstractDemo(a, b) {
x = a;
y = b;
}
public function area() {
}
}
--------
firstObj.as :
class firstObj extends AbstractDemo {
public function firstObj(a, b) {
super(a, b);
}
public function area() {
return x*y;
}
}
--------
AbstractArea.as :
class AbstractArea {
var r:firstObj;
var a:AbstractDemo;
public function AbstractArea() {
r = new firstObj(10, 9);
a = r;
trace(a.area());
}
}
----------
test.fla:
myobj=new AbstractArea()
回复Comments
作者:
{commentrecontent}