From: Scott A. L. <sc...@sc...> - 2000-12-11 23:01:39
|
> Wouldn't it be better to say: > MyObject.prototype = DynObject.prototype I think this would cause problems when more than one object inherits from the DynObject. Using "new" ensures that the widget prototype is unique and won't be shared with other widgets that also use DynObject as their parent class. For example: let's say you have two widgets that inherit from DynObject, Widget A and Widget B: WidgetA.prototype = DynObject.protoype WidgetB.prototype = DynObject.protoype If Widget A overwrites a method of DynObject, it will also overwrite it for Widget B, because they share the prototype of DynObject: WidgetA.prototype.setSize = function(){ /*whatever*/} <-- this will overwrite the method for WidgetB, too. So I would think that using "new DynObject" instead would keep these unique and seperate. However, you brought up a very good point earlier in that using "new DynLayer" to create the prototypes for widgets creates an instance of DynLayer that ends up in the unassigned array: WidgetA.prototype = new DynLayer(); <-- this is a new instance, and ends up in unassigned[] This is probably not fatal, though, as it never gets assigned to a document. But it happens for every widget that uses this method. -- scott andrew lepera ----------------------------------- web stuff: www.scottandrew.com music stuff: www.walkingbirds.com |