Hi there!
Why if i try:
Object(n) //Constructor { this.member = n; } Object.prototype.alertX = function()// Method { alert(this.member); } foo = new Object(4); Object.alertX;
I get "this. member is not defined".
How can i access the constructor's member inside one of its methods?
EDITED: my original purpose is to have an internal method access the already created object member, not to access the object's method from creating another object, the object is already created!
Thanks!
EDITED 2:
Tried this:
var fooObj = function(x,y,z){ // Map object constuctor.
this.x = x;
this.y = y;
this.z = y;
}
fooObj.prototype.test = function(){
alert(this.x);
}
***initialization****
something = new fooObj();
something.otherMethod(x,y,z); <--- draws an object, a canvas, for example.
document.getElementById('canvas').addEventListener('mouseup', something.test, false);
When i press over the object, should fire of the alert, but get the this.x not defined. Do i have to give it a value? The object was already created and executed one of its functions!