From: Raymond I. <xw...@ya...> - 2003-07-28 14:26:28
|
I think we need to sort out the delete and remove functions. IMO when we call delete it should destroy the layer and remove it from the parent. When the remove functions are call it should only remove the layer but does not destroy it, correct? Are we all in agreement here? To fix the memory and layer problem use the following: p.deleteAllChildren = function() { var c,l = this.children.length; for(var i=0;i<l;i++) { c=this.children[i]; if(c) { c._destroy(); c._created = c.isChild = false; }; delete this.children[i]; } this.children.length = 0; }; --- Andrew Gillett <an...@zo...> wrote: > Hi, > > Attached is an HTML file that illustrates a problem > I've had with > DynAPI3. The page contains two buttons and creates a > DynLayer in its > "init" method. When the "Add layers" button is > pressed, three new > DynLayers are added to the top level layer - no > problem. When the > "Remove layers" button is pressed, the > deleteAllChildren method is > called on the top DynLayer, but only the first two > child layers > disappear - the third one stays put. This problem > occurs on IE5, IE6 and > Mozilla1.3. > > While looking at the "deleteAllChidren" function in > src/api/event.js, I > found that I could fix the problem (sort of) by > changing direction of > the "for" loop on line 164 from: > for(var i=0;i<l;i++){ > to > for(var i=l-1;i>=0;i--){ > however I don't understand why this change would > make any difference. > And it leaks memory with or without my change, so I > expect that it isn't > a proper fix in any case. > > So, is this a bug or am I simply doing something > wrong? > > regards, > Andrew Gillett > > --------------------------------- dynapi.library.setPath('../src/');dynapi.library.include('dynapi.api');dynapi.onLoad(init);var topLayer;function init(){ topLayer=new DynLayer(null,10,50,200,100,'yellow'); dynapi.document.addChild(topLayer);}function addLayers(){ for (var i=0;iAdd LayersRemove Layers __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com |