I have been trying many ways to accomplish this without any success. Can anybody help me?
Base Object:
var Recorder = function (source) {
this.context = source.context;
var recording = null;
this.start = function () {
recording = true;
}
this.stop = function () {
recording = false;
}
}
Derived Object:
var messageRecorder = function () {
this.isRecording = function () {
return this.recording;
}
}
So I have a base object, Recorder, which has a var 'recording'. I want to have an extended/derived object, messageRecorder, which can return the value of 'recording' (from Recorder). Any suggestions? I have tried the jQuery extend, var audioRecorder = $.extend( {}, new Recorder(), new messageRecorder()), with no luck. I have also tried to modify messageRecording as follows:
var messageRecorder = function () {
Recorder.apple(this, arguments);
this.isRecording = function () {
return this.recording; //declared in Recorder
}
}
and instantiate like so: var audioRecorder = new messageRecorder(source);
In both my failed attempts, when I call audioRecorder.start() it works fine. When I call audioRecorder.isRecording(), the var 'recording' is undefined, probably because I am not trying to access it properly. Any suggestions?