Error?

0 Landon Luman · February 12, 2015
So can someone help me figure out the errors in my ways? Enough with the formal talk, what did I do wrong?


var ctx = document.getElementById('ctx').getContext('2d');
setInterval(function(){
ctx.mouseDown = function(event) {
ctx.fillRect(event.clientX,event.clientY,1,1);
};
},10)

Post a Reply

Replies

Oldest  Newest  Rating
0 danial saufi · February 12, 2015
y is there a ,10) at the end of ur code??
+1 Jay Deshaun · February 12, 2015
var ctx = document.getElementById('ctx').getContext('2d');
setInterval(
function(){
ctx.onMouseDown = (function(event){
ctx.fillRect(event.clientX,event.clientY,1,1);
});
},10);


You forgot the ';' at the end of your code, and it's 'onMouseDown' not 'mouseDown'.

@danial it's the time in milliseconds, see more here:
http://www.w3schools.com/js/js_timing.asp
0 Mr. Computer · February 12, 2015

var ctx = document.getElementById('ctx').getContext('2d');
setInterval(function(){
ctx.onMouseDown = function(event) {
ctx.fillRect(event.clientX,event.clientY,1,1);
};
},10);
  • 1

Javascript

107,196 followers
About

A scripting language that is added to standard HTML to create interactive effects, apps, games for the browser.

Links
Moderators