抽象类在AS中的使用方法

      Flash 2005-2-24 17:34
共分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()
标签集:TAGS:
回复Comments() 点击Count()

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}