Is there anyway to select a particular instantiated object of a HTML5 Canvas ("this" pointer) after a mouse click from inside that particular canvas? Keep in mind that "Canvas" method I have shown is a non-standard function that I made up.
function Canvas(element) {
this.canvas = document.createElement("canvas");
this.context = this.canvas.getContext('2d');
this.canvas.id = "display";
var style = {"width" : "500",
"height" : "500"};
for(var index in style) {
this.canvas[index] = style[index];
}
element == undefined ? document.body.appendChild(this.canvas) : element.appendChild(this.canvas);
this.canvas.addEventListener("click", this.click, false);
}
then in a prototyped function I have...
Canvas.prototype.click = function(e) {
this.mouse = [e.clientX, e.clientY];
return this.of(this.mouse);
}
Error: this.of(this.mouse) doesn't exist however I have a prototype for this function (later on) in my code.