I'm trying to create a class that's not going to be instantiated and used just for other classes to inherit, but I can't seem to get it to work. Here's what I'm doing:
then in an alias called test I do:
t1 notes correctly, but where t2 writes "should have inherited testVar and the value is: undefined"
I'm guessing this is because almost everything in the script file has to be called through a function(not sure if this is correct) and this means the line doesn't get processed. I'm wandering if there is a way to deal with this?
function TestObject()
{
this.testVar = 1;
this.write = writing;
function writing()
{
world.note("writing from TestObject");
}
}
TestingObject.prototype = new TestObject();
function TestingObject()
{
this.write = writing;
function writing()
{
world.note("should have inherited testVar and the value is: " + this.testVar);
}
}
then in an alias called test I do:
var t1 = new TestObject();
var t2 = new TestingObject();
t1.write();
t2.write();
t1 notes correctly, but where t2 writes "should have inherited testVar and the value is: undefined"
I'm guessing this is because almost everything in the script file has to be called through a function(not sure if this is correct) and this means the
TestingObject.prototype = new TestObject();