So I think I'm going crazy here. I'm trying to use prototype in my code, so I will have a Layer object that will have a Figure Object that will have a _newFigure function.
Layer = function(){}
Layer.prototype.figure = function(){}
Layer.prototype.figure.prototype._newFigure = function(){
//(Creates new Figure)
}
What I'm expecting in pseudo-code:
[LayerObject]{
figure:{
_newFigure:function(){
//(Creates new Figure)
}
}
}
Now that, to me, would be the logical thing to do, but for some reason it doens't work. Do you now how can I achieve that? Keep in mind I'm using prototype for performance reasons.
-- thanks in advance --
UPDATE---------------------------------------------------------------------------------------
As Nick said "Why does Layer need to have a Figure on it's prototype? It seems like Layer and Figure our separate entities, and a Layer can have a Figure instance attached to it. Just a thought : )"
So, I've updated the code (now working)
Layer = function(){
this.figure = new figureHandler(this);
}
function figureHandler(layer){
this.layer = layer;
}
figureHandler.prototype._newFigure = function(){
//(Creates new Figure)
}
-- See ya! Thanks for your help :) --