The whole prototype code is THE way that Javascript does inheriting (read
the Netscape references) The problem we are facing is something we did our
selves, in the constructor we should only SET the properties, not create
properties or methods, that causes problems.

This also means that the oncreate eventlistener is not correct, I think we
should restate the oncreate method of an object, because that makes it work
correctly in multy-chain inheriting. See my latest preview release of
dynacore, the image button inherites from the button which inherits from the
dynLayer which inherits from the DynObject.. that's multi chain inheriting
with events and everything working correctly.

The only problem, as Robert pointed out, is the unassigned element with the
wrong ID, this is the only thing I have to get out but the problem exists
because we are creating a new array-element in the constructor.. which
should not be done.

Note that this problem only exists because we overwrite the ID value in
later object constructors.



Pascal Bestebroer
[EMAIL PROTECTED]
http://www.oibv.com


-----Oorspronkelijk bericht-----
Van: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]Namens Scott Andrew
LePera
Verzonden: dinsdag 12 december 2000 8:49
Aan: [EMAIL PROTECTED]
Onderwerp: Re: [Dynapi-Dev] Inheritance


On the face of it I don't think it's entirely necessary unless your goal is
to create a large hierarchy of objects, in which case you could just use the
SuperClass object as your base object and subclass everything from there.

The WidgetX model will create an extra instance of the DynLayer class in the
DynLayer unassigned[] collection, for every constructor that uses
"WidgetName.prototype = new DynLayer();" to fake inheritance.  But that
shouldn't break anything, just as long as unassigned[] remains private and
you don't loop through it for anything.

------
scott andrew lepera
[EMAIL PROTECTED]
web stuff: www.scottandrew.com
music stuff: www.walkingbirds.com


-----Original Message-----
From: Brandon Myers <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Monday, December 11, 2000 6:14 PM
Subject: RE: [Dynapi-Dev] Inheritance


>>> Wouldn't it be better to say:
>>> MyObject.prototype = DynObject.prototype
>
>>I guess this would only create a pointer, so that changes to
>>MyObject.prototype would affect DynObject.prototype
>
>Very good point.. so should we then loop through the prototypes?..
>Assigning the individual functions, but not the entire prototype?
>Do this to avoid setting variables or objects which would then be shared by
>all instances of the subclass.
>
>function Label() {
> this.theLayer=new DynLayer();
>}
>
>Label.prototype=new DynObject();
>
>Then.....
>
>function Button() {
> this.theLayer.addEventListner(Button.mouseEvents);
>// More stuff here too.
>}
>Button.mouseEvents=...blah blah blah....
>Button.prototype=new Label(); // Cause a button is just a label with
events.
>
>Now.. guess what? All instances of Button will share the same DynLayer
>reference.
>Is this what is intended? I don't think so.
>
>Now.. don't get on my case that I used Dan's original widget model.. it's
>just a practical example. Any object in place of the "theLayer" object
would
>have the same problems.
>
>-----Original Message-----
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED]]On Behalf Of Simon Dicon
>Montford
>Sent: Monday, December 11, 2000 6:12 PM
>To: [EMAIL PROTECTED]
>Subject: RE: [Dynapi-Dev] Inheritance
>
>
>> I was wondering the point of this line when inheriting objects:
>>
>> MyObject.prototype = new DynObject();
>
>It's so that any changes to DynObject.prototype at runtime will
>be reflected in MyObject.prototype
>
>> Wouldn't it be better to say:
>> MyObject.prototype = DynObject.prototype
>
>I guess this would only create a pointer, so that changes to
>MyObject.prototype would affect DynObject.prototype
>
>SD
>_______________________________________________
>Dynapi-Dev mailing list
>[EMAIL PROTECTED]
>http://lists.sourceforge.net/mailman/listinfo/dynapi-dev
>
>_______________________________________________
>Dynapi-Dev mailing list
>[EMAIL PROTECTED]
>http://lists.sourceforge.net/mailman/listinfo/dynapi-dev
>

_______________________________________________
Dynapi-Dev mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/mailman/listinfo/dynapi-dev

_______________________________________________
Dynapi-Dev mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/mailman/listinfo/dynapi-dev

Reply via email to