Entry
Can someone give me a working example of a class that inherits the properties of the built in Image Ojbect?
Jan 17th, 2001 14:36
Mike Moretti, Hayden Porter,
function ImageSubClass() {
this.extraproperty = 1;
}
// Subclass Image
ImageSubClass.prototype = new Image();
// Now let's add a function for the subclass
ImageSubClass.prototype.getExtraProperty = function() { return
(this.extraproperty); };
// Now you can create a new ImageSubClass and it will have all
// properties of Image as well as ImageSubClass
var isc = new ImageSubClass();
isc.src = "somegiffile.gif";
alert(isc.getExtraProperty() + " " + isc.width);