[General] Fwd: Why using Object.extend?
Robert Krahn
robert.krahn at student.hpi.uni-potsdam.de
Sat Apr 25 14:44:26 CEST 2009
Hi, Haowei.
Those properties and functions defined in the subclass construct are
defined for instances of the class, i.e. they are added to the
prototype property of a class. Object.extend, however, adds functions
and properties directly to the given object, not its prototype property.
Robert
On Apr 25, 2009, at 2:16 PM, Haowei Ruan wrote:
> 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))
> });
> ---------------------------------------------------------
> _______________________________________________
> General mailing list
> General at livelykernel.sunlabs.com
> http://livelykernel.sunlabs.com/mailman/listinfo/general
More information about the lively-kernel
mailing list