[General] Why using Object.extend?

Haowei Ruan haowei.ruan at gmail.com
Sat Apr 25 14:16:09 CEST 2009


Hi, i do not understand why still uses Object.extend, can't those
properties be defined within the "subclass" construct?
Thanks in advance!

regards,
Haowei

code snippet:
--------------------------------------------------------
Gradient.subclass("LinearGradient", {

    initialize: function($super, stopColor1, stopColor2, vector) {
        vector = vector || LinearGradient.NorthSouth;
        this.rawNode = NodeFactory.create("linearGradient",
                       {x1: vector.x, y1: vector.y,
                        x2: vector.maxX(), y2: vector.maxY()});
        this.addStop(0, stopColor1).addStop(1, stopColor2);
        return this;
    }

});

Object.extend(LinearGradient, {
    NorthSouth: rect(pt(0, 0), pt(0, 1)),
    SouthNorth: rect(pt(0, 1), pt(0, 0)),
    EastWest:   rect(pt(0, 0), pt(1, 0)),
    WestEast:   rect(pt(1, 0), pt(0, 0))
});
---------------------------------------------------------




More information about the lively-kernel mailing list