Aha, I figured out a solution. I just added an if (l.parent) before
l.parent.animateMe(); and it's working fine. I'm guessing it's due to event
bubbling...
-Anarchos
----Original Message Follows----
From: "Anarchos -" <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Re: [Dynapi-Help] Referencing parent in NS
Date: Mon, 25 Jun 2001 20:07:43 -0000
Thank you for the suggestion; I tried changing "layer" but I'm still getting
the errors =(. I can't upload the newer version at this moment though.
The reason I have that setBack code in the onprecreate is because I have
buttons that are added to the menu after it has been created, and the menu
then resizes itself to fit the new buttons (trying to use good OOD).
Once again, the html is at http://anarchos.xs.mw/dhtml/anarmenu.phtml you
can view the source at
http://anarchos.xs.mw/source.phtml?page_url=/dhtml/anarmenu.js
Thanks,
Anarchos
=====================================================
I think the big mistake is using the reserved word "layer" (NS4 won't like
that)
you could also move this (changed) part into the constructor:
this.setBack = new DynLayer(null,o.w-15,o.h-5,10,3,"#000000");
this.setBack.listener = new EventListener();
this.setBack.listener.onclick = function(e){
var o= e.getSource();
o.parent.animateMe();
};
and keep this bit in onprecreate:
o.setBack.addEventListener(o.setBack.listener);
o.addChild(o.setBack);
Try it though, I'm not sure.
Cheers,
Richard Bennett
[EMAIL PROTECTED]
www.richardinfo.com
(Everything running on, and ported to DynAPI2.53)
visit the DynAPI homepage (and FAQ) ::
http://dynapi.sourceforge.net/dynapi/index.php?menu=1
Browse (and search) the mailinglist here:
http://www.mail-archive.com/index.php3?hunt=dynapi
----- Original Message -----
From: "Anarchos -" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: 17 June, 2001 06:05
Subject: [Dynapi-Help] Referencing parent in NS
>Hey there, this is my first dynapi script so I could be doing very
something
>entirely wrong...the problem is that I have a DynLayer that should make
its
>parent slideTo() certain coordinates when the child layer is clicked.
Here's
>the important code (from the onprecreate() of the parent):
>
>o.setBack = new DynLayer(null,o.w-15,o.h-5,10,3,"#000000");
>o.setBack.listener = new EventListener();
>
>o.setBack.listener.onclick = function(e){
> var layer = e.getSource();
> layer.parent.animateMe();
>};
>
>o.setBack.addEventListener(o.setBack.listener);
>o.addChild(o.setBack);
>
>This works perfectly on IE 5, but on NS 4/6 it gives multiple errors about
>parent not having any properties, but then proceeds to slideTo the parent
>correctly (but really slow in NS6). The html is at
>http://anarchos.xs.mw/dhtml/anarmenu.phtml you can view the source at
>http://anarchos.xs.mw/source.phtml?page_url=/dhtml/anarmenu.js
>
>Thanks a bunch,
>Anarchos
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com
_______________________________________________
Dynapi-Help mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-help