I have an issue with making an image of an object clickable this is the code:
// JavaScript Document
// Create the canvas
var canvas = document.createElement("canvas");
var ctx = canvas.getContext("2d");
canvas.width = 512;
canvas.height = 512;
//draw canvas
document.body.appendChild(canvas);
var x=30;
var y=30;
var icon1 = new Object();
icon1.id=1;
icon1.selected=false;
icon1.img1 = new Image();
icon1.img1.onload = function() {
ctx.drawImage(icon1.img1, 69, 50,x,y);
};
icon1.img1.src = 'images/hero.png';
icon1.img1.clicked = function()
{ alert('blah'); };
it previews the icon but when I click it nothing happens , is the javascript coding correct?
ALso tried at first onclick but the same nothing appears when clicking the icon