|
From: Robert R. <rra...@ya...> - 2001-01-22 16:37:05
|
Why do you say this:
> l.oncreate=function(e) {
> if (this.created) return
That seems like an odd way to do it. In that statement this.created, I
don't think this.created will ever be true, since this is not a
DynLayer object. Why do you have all of that code in the create event?
You should make the events static objects like:
lxbutton.events = new EventListener()
Why don't you go ahead and create the DynLayer's in the constructor,
and then just resize them on the create event.
--
// Robert Rainwater
On 1/22/2001, 11:22:55 AM EST, Michele wrote about "[Dynapi-Widgetdev] NS often crashes with a simple widget ...":
> Hi all,
> I'm trying to use DynAPI to built my personal widgets, but I found some
> misteriuos crashing when resizing NS (4.72) on NT 4.0 (NS 4.72 on Linux
> RedHat 6.2 works fine; also with IE 5.5 works fine).
> I didn't understand your answers very well on this arguments ...
> Try resizing this example ("lxbutton.js" is my widget rollover button) for
> about 10 times and you'll see the crashing:
> (Note I dont' re-create the widget in l.oncrerate() event!)
> --- code of "lxbutton.js" -----------
> function lxbutton(x,y,w,h,caption,color,bdc1,bdc2,rollOver) {
> this.superClass=DynLayer
> this.superClass()
> this.id="lxbutton"+(lxbutton.Count++)
> this.moveTo(x||0,y||0)
> this.setSize(w||128,h||36)
> this.caption=caption||''
> var l=new EventListener(this)
> l.oncreate=function(e) {
> if (this.created) return
> o=e.getTarget()
> o.setBgColor(color)
> c1=color
> c2=color
> if (!rollOver) {
> c1=bdc1
> c2=bdc2
> }
> o.BorderL=new DynLayer(null,0,0,1,o.h,c1)
> o.BorderT=new DynLayer(null,0,0,o.w,1,c1)
> o.BorderR=new DynLayer(null,o.w-1,1,1,o.h-1,c2)
> o.BorderB=new DynLayer(null,1,o.h-1,o.w-1,1,c2)
> o.addChild(o.BorderL)
> o.addChild(o.BorderT)
> o.addChild(o.BorderR)
> o.addChild(o.BorderB)
> x1=6
> x2=6
> if (!rollOver) {
> x1=5
> x2=5
> }
> o.dyncaption=new DynLayer(null,x1,x2,o.w-6,o.h-6)
> o.dyncaption.setHTML(o.caption)
> o.addChild(o.dyncaption)
> if (!is.ns) o.dyncaption.addEventListener(o.events)
> o.dynevents = new DynLayer(null,0,0,o.w,o.h)
> if (!is.ns) o.dynevents.addEventListener(o.events)
> o.addChild(o.dynevents)
> o.setVisible(true)
> this.created=true
> }
> this.addEventListener(l)
> this.events=new EventListener(this)
> this.events.onmousedown=function(e)
> o=e.getTarget()
> o.BorderL.setBgColor(bdc2)
> o.BorderR.setBgColor(bdc1)
> o.BorderT.setBgColor(bdc2)
> o.BorderB.setBgColor(bdc1)
> o.dyncaption.moveTo(6,6)
> }
> this.events.onmouseup=function(e) {
> o=e.getTarget()
> o.BorderL.setBgColor(bdc1)
> o.BorderR.setBgColor(bdc2)
> o.BorderT.setBgColor(bdc1)
> o.BorderB.setBgColor(bdc2)
> o.invokeEvent("click")
> o.dyncaption.moveTo(5,5)
> }
> if (rollOver)
> this.events.onmouseover=function(e){
> o=e.getTarget()
> o.BorderL.setBgColor(bdc1)
> o.BorderR.setBgColor(bdc2)
> o.BorderT.setBgColor(bdc1)
> o.BorderB.setBgColor(bdc2)
> o.dyncaption.moveTo(5,5)
> }
> this.events.onmouseout=function(e){
> o=e.getTarget()
> o.BorderL.setBgColor(color)
> o.BorderR.setBgColor(color)
> o.BorderT.setBgColor(color)
> o.BorderB.setBgColor(color)
> o.dyncaption.moveTo(6,6)
> }
> }
> if (is.ns) this.addEventListener(this.events)
> return this
> }
> lxbutton.Count=0
> lxbutton.prototype=new DynLayer()
> lxbutton.prototype.getSubClass=function() { return lxbutton }
> ------ code of "test.html" --------
> <html>
> <head><title>DynAPI2 tutor - button widget</title>
> <Script language="Javascript" src="./js/dynapi.js"></script>
> <Script language="Javascript">
> DynAPI.setLibraryPath('./js/lib/')
> DynAPI.include('dynapi.api.*')
> </script>
> <Script language="Javascript" src="./lxbutton.js">
> </script>
> <Script language="Javascript">
> DynAPI.onLoad=function() {
> // a no-rollover button
> myButton=new lxbutton(50,50,220,60,'<img src="logo.gif">Click
> Me','#c0c0c0','#f0f0f0','#808080',false)
> DynAPI.document.addChild(myButton)
> // 3 rollover buttons
> layer=new DynLayer(null,280,20,350,400,'#b21104')
> DynAPI.document.addChild(layer)
> myLxButton0=new lxbutton(50,50,260,60,'<img src="logo.gif">Click and Over
> Me','#b21104','#ffffff','#808080',true)
> layer.addChild(myLxButton0)
> myLxButton1=new lxbutton(50,120,260,60,'<img src="logo.gif">Click and Over
> Me','#b21104','#ffffff','#808080',true)
> layer.addChild(myLxButton1)
> myLxButton2=new lxbutton(50,190,260,60,'<img src="logo.gif">Click and Over
> Me','#b21104','#ffffff','#808080',true)
> layer.addChild(myLxButton2)
> }
> </script>
> </head>
> <body>
> </body>
> </html>
> So, what is my error?
> Thanx in advance.
> Michele Muner.
> _______________________________________________
> Dynapi-Widgetdev mailing list
> Dyn...@li...
> http://lists.sourceforge.net/lists/listinfo/dynapi-widgetdev
|