J
Jim Red
hello
first of all, i know, there are no classes in javascript. but i will use
that word for better understanding of my question.
here we go. i have three classes and need a reference to the parent class.
could this be done by a reference, or just by constructing the class.
function Class1() {
this.class2 = new Class2();
this.class3 = new Class3();
}
function Class2() {
this.variable = "hello world";
}
function Class3() {
// just for this example. is not working
alert(_parent.class2.variable);
}
var class1 = new Class1();
in flash, we could use'_parent'. is there another way to get a reference
to the class1 in javascript?
Of course, i can pass the this pointer. But I'm wondering if theres
another possibility.
function Class1() {
this.class2 = new Class2(this);
this.class3 = new Class3(this);
}
function Class2(_parent) {
this.variable = "hello world";
}
function Class3(_parent) {
alert(_parent.class2.variable);
}
Thanks for any advise.
//jim
first of all, i know, there are no classes in javascript. but i will use
that word for better understanding of my question.
here we go. i have three classes and need a reference to the parent class.
could this be done by a reference, or just by constructing the class.
function Class1() {
this.class2 = new Class2();
this.class3 = new Class3();
}
function Class2() {
this.variable = "hello world";
}
function Class3() {
// just for this example. is not working
alert(_parent.class2.variable);
}
var class1 = new Class1();
in flash, we could use'_parent'. is there another way to get a reference
to the class1 in javascript?
Of course, i can pass the this pointer. But I'm wondering if theres
another possibility.
function Class1() {
this.class2 = new Class2(this);
this.class3 = new Class3(this);
}
function Class2(_parent) {
this.variable = "hello world";
}
function Class3(_parent) {
alert(_parent.class2.variable);
}
Thanks for any advise.
//jim