From: labCoat <la...@xe...> - 2001-01-21 23:05:49
|
First of all, I would like to say that I am back from hiding :-) -- I know that I have been out of the loop for a while and have not been able to keep up with what is going on too much, but after looking over the newest (CVS) release, and reading 987,345,276,765,575 emails :-), I think that I am up to speed, and would like to start contributing again! now to the problem at hand... I have run into the same error before. I had a layer ("layerA") that had a child layer ("layerA_child"). "layerA" was already added to the document, and when I removed the layer from the document and then added it to another layer, I got the error that "layerA_child" was already added to the document. The problem is with the removeChild/removeFromParent methods of the DynLayer. When you call a remove method of a layer, one of the things that it does is to remove the specified layer from the all array, and add it to the unassigned array, but it never does that with it's children. I came up with a quick-fix (don't know how good it works in all situations, but I can't think of any where it won't work :-)). I added the DynLayer method: <!--// /* DynLayer.prototype.removeAllChildren=function() { var child; for (var i in this.children) { child=this.children[i]; child.removeAllChildren(); DynAPI.removeFromArray(this.dyndoc.all,child,true); DynLayer.unassigned[child.id]=child; } }; */ //--> And then, I call removeAllChildren from removeChild, as shown below. <!--// /* DynLayer.prototype.removeChild=function() { var child; for (var a=0; a<arguments.length; a++) { child=arguments[a]; // FIX: MAKE CALL HERE child.removeAllChildren(); //END FIX if (child.parent==this) { DynAPI.removeFromArray(this.children,child); DynAPI.removeFromArray(this.dyndoc.all,child,true); DynLayer.unassigned[child.id]=child; DynLayer.deleteElement(child); child.parent=null; child.isChild=false; } } return arguments[arguments.length-1]; }; */ //--> It takes all of the children layers of the 'removed' layer, and also removes them from the all array, and adds them to the unassigned array, so that when you add it to a document or to another layer, you do not get that error. Is this worthy of a patch, or just a duct-tape fix? If there is a better way to do this, I would appriciate some feedback :-) --proteanman On Sun, 21 January 2001, "Eytan Heidingsfeld" wrote: > > Hi, > I've been working on something both at home and at work. I brought these > files home and suddenly get these errors JSDynlayer0 is already in > DynDocument you must remove it first and also elm.all is undefined. What is > going on?? > > > _______________________________________________ > Dynapi-Dev mailing list > Dyn...@li... > http://lists.sourceforge.net/lists/listinfo/dynapi-dev |