to clarify.  the "inheretance" is done in the prototype=new DynLayer() line.
the lines that you are talking about is the "initialisation" segment.  this is where many of the individual variables such as ID and default values are specificed.

In some cases, it is possible to leave this out.  eg:

    DynEvent=function(type,src,target) {
        this.type=type;
        this.src="src;
        this.target=target;
        return this;
    };

    DynEvent.Mouse=function() { return this; };
    DynEvent.Mouse.prototype=new DynEvent;

Since when we create a mouse event, we do not know the values, we leave them as the default values.  In this case, there is no need to call the super constructor.  This is the same for Java.  If you don't need any variables to be passed to the super constructor, this is no need to call it.

Digital Strider wrote:

A better answer.

Most widgets inherit from some class (superClass), be it DynLayer, DynImage,
Viewport or another.  This means you can use the methods of the superclass
with implicit calls such as:

myLayer.setBgImage

without it you would be allot more verbose

SuperWidgetSetImage(img) {
        var img = img
        DynLayer.setBgImage(img)
}

A interesting Widget to study is Scrollpane.  It uses a sloppy form of
multiple inheritance.  It inherits from Viewport but if you look way down on
the bottom you will see explicit calls to "DynImage.getImage()" in the
MetalScrollPane() function.  Since it doesn't inherit from DynImage these
called need to be explicit.

Hope it helps,

Ray

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Colin
Thompson
Sent: Saturday, May 12, 2001 1:00 AM
To: Dynapi-Help
Subject: [Dynapi-Help] correct format of widgets

Just a simple question,

I've noticed that the tutorials by Pascal use this format:

        function widget(id,x,y,w,h) {
                this.superClass=DynLayer
                this.superClass(id,x,y,w,h)

yet all the 'core' widgets use this.DynLayer. What is the difference between
the 2? is there a consequence of using one over the other?

_______________________________________________
Dynapi-Help mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-help

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.252 / Virus Database: 125 - Release Date: 5/9/2001

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.252 / Virus Database: 125 - Release Date: 5/9/2001

_______________________________________________
Dynapi-Help mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-help

--
Michael Pemberton
[EMAIL PROTECTED]
ICQ: 12107010
 

Reply via email to