From: Bartek <ba...@ho...> - 2000-11-23 23:41:34
|
I was wondering whether it is a good idea to have some inheritible = constructor functionality for DynLayer. I want to be able to create a widget object that extends the DynLayer = and inherits its initialization, i.e so I wouldn't have to rewrite the = initialization code for the widget but instead do something like this: ------------------------------------------ function WidgetLayer(){ this.construct(arguments) } WidgetLayer.prototype=3Dnew DynLayer ------------------------------------------------------ and it would look something like this for dynlayer: --------------------------------------------------------------------- function DynLayer(){ this.construct(arguments) } DynLayer.prototype.construct=3Dfunction(){ alert() var a=3Darguments if (a.length=3D=3D1 && a[0]!=3Dnull && typeof(a[0])=3D=3D"object") = this.setStyle(a[0]) else { this.id=3Da[0]||"JSDynLayer"+(DynLayer.nullCount++) this.x=3Da[1]||0 .......etc... } } -------------------------------------------------------------------------= -- I am trying to implent this as I write, to test it out, and I'm having = some problems. Maybe there is a better way of doing this... If so , please let me know. = :) Or am I on the right track? /Bart |
From: Dan S. <dy...@fu...> - 2000-11-24 00:37:04
|
Just make your widget constructor call the DynLayer as a method: function widget(arguments) { this.DynLayer = DynLayer this.Dynlayer(arguments) } widget.prototype = new DynLayer Dan On Fri, Nov 24, 2000 at 12:39:05AM +0100, Bartek wrote: > I was wondering whether it is a good idea to have some inheritible constructor functionality for DynLayer. > I want to be able to create a widget object that extends the DynLayer and inherits its initialization, i.e so I wouldn't have to rewrite the initialization code for the widget but instead do something like this: > > ------------------------------------------ > > function WidgetLayer(){ > this.construct(arguments) > } > WidgetLayer.prototype=new DynLayer > > ------------------------------------------------------ > > and it would look something like this for dynlayer: > > --------------------------------------------------------------------- > > function DynLayer(){ this.construct(arguments) } > DynLayer.prototype.construct=function(){ > alert() > var a=arguments > if (a.length==1 && a[0]!=null && typeof(a[0])=="object") this.setStyle(a[0]) > else { > this.id=a[0]||"JSDynLayer"+(DynLayer.nullCount++) > this.x=a[1]||0 > .......etc... > } > } > > --------------------------------------------------------------------------- > > I am trying to implent this as I write, to test it out, and I'm having some problems. > Maybe there is a better way of doing this... If so , please let me know. :) > Or am I on the right track? > > > /Bart |
From: Brandon M. <bnd...@ho...> - 2000-11-25 01:40:24
|
How to register as a developer?Guys... don't sweat he small stuff. All = of this has already been completed. If you go back about 3-4 months ago I wrote a little file called = SuperClass.js. Based on this class I have been able to get complete object based = inheritance to work. It took a few weeks, but it works. Just look at that code from way back = when. It needs work as it is, but it's basis is sound. ----- Original Message -----=20 From: Bartek=20 To: dyn...@li...=20 Sent: Thursday, November 23, 2000 6:39 PM Subject: [Dynapi-Dev] Widget constructor I was wondering whether it is a good idea to have some inheritible = constructor functionality for DynLayer. I want to be able to create a widget object that extends the DynLayer = and inherits its initialization, i.e so I wouldn't have to rewrite the = initialization code for the widget but instead do something like this: =20 ------------------------------------------ =20 function WidgetLayer(){ this.construct(arguments) } WidgetLayer.prototype=3Dnew DynLayer =20 ------------------------------------------------------ =20 and it would look something like this for dynlayer: =20 --------------------------------------------------------------------- =20 function DynLayer(){ this.construct(arguments) } DynLayer.prototype.construct=3Dfunction(){ alert() var a=3Darguments if (a.length=3D=3D1 && a[0]!=3Dnull && = typeof(a[0])=3D=3D"object") this.setStyle(a[0]) else { this.id=3Da[0]||"JSDynLayer"+(DynLayer.nullCount++) this.x=3Da[1]||0 .......etc... } } =20 = -------------------------------------------------------------------------= -- =20 I am trying to implent this as I write, to test it out, and I'm having = some problems. Maybe there is a better way of doing this... If so , please let me = know. :) Or am I on the right track? =20 =20 /Bart |