PDA

View Full Version : MX OOP Inheritance and callback's



Johnny64
September 29th, 2003, 01:05 PM
Hoi

i made an example so i can explein the prob better



Class = function () {};
Class.prototype.getTheData = function() {
this.vars = new LoadVars();
this.vars.onLoad = function() {
this.callback();//<= prob here
};
this.vars.load("data.php");
};
//
myDataThing = new Class();
myDataThing.callback = function() {
trace("ok");
};
myDataThing.getTheData();

I am making a class and if have another build in object in it. I what to add a callback to it but the inheritance is not right. I know how the set up inheritance
1) subClass.prototype.__proto__ = superClass.prototype;
2) subClass.prototype. = new superClass;
but its all messed up in my head so I was hoping someone could point me in the right direction on how to get the callback to work with out messing up the LoadVars class too much.


:) thanks

senocular
September 29th, 2003, 01:09 PM
Class = function () {};
Class.prototype.getTheData = function() {
this.vars = new LoadVars();
this.vars._parent = this;
this.vars.onLoad = function() {
this._parent.callback();
};
this.vars.load("data.php");
};
//
myDataThing = new Class();
myDataThing.callback = function() {
trace("ok");
};
myDataThing.getTheData();

Johnny64
September 29th, 2003, 01:18 PM
:) =) :beam: :bu: :thumb:

thanks i have been hitting my head for days trying the get it to work
thanks

senocular
September 29th, 2003, 01:18 PM
welcome http://userpages.umbc.edu/~tmccau1/flash/kirupa/pixelsen.gif