Pascal,
A few issues:
1. Memory footprints of the actual objects (DynLayer) and not the elements
should be able to be released (gotta check that out).
2. Backwards compatibility is the word (or phrase). We add a method (listed
as deprecated) called addChild which sets the child's parent to self and
creates it something like this:
DynLayer.prototype.addChild = function(chld){
chld.owner = this;
chld.create();
}
That's all you need!!
3. First of all about if statements they take no time (basically) they are
not what is slowing you down. I will explain the difference between my
passing of objects and yours. Since JS has no pointers JS automatically
manages them. That means that an object is created once and then can be
passed but is passed as a pointer (anyone have tech stuff about this??).
What I do is as such
new Canvas(owner)
this.owner = owner;
JS interprets this as such:
1. Take pointer of owner
2. Replace the pointer of this.owner to the pointer of owner
3. Only once the object is passed and it is passed as a pointer. JS doesn't
need to call anything currently from this object just set up a pointer to
it.
DynLayer way:
new DynLayer()
addChild
Create element.
Pass DynLayer and Element to static function
Static function must take both objects and take the DynLayer as an object
and set up this.elm to point to Element
As you can see (here and in the tests) my way is more effective. It is also
logically more effective because each layer has his own responsibility to
create himself and doesn't have to delegate this responsibility to his
parent.
8an
_______________________________________________
Dynapi-Dev mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-dev