Friday, 15 April 2011

javascript - Unusual error with string in canvas in Firefox -



javascript - Unusual error with string in canvas in Firefox -

i tried create falling snow in canvas. code works ok in chrome in ff18 nil displayed.

http://dharman.eu/flakes/

when checked in console firebug throws error: an invalid or illegal string specified var s = flakes[flake].chara; ctx.filltext(s,flakes[flake].x, flakes[flake].y);

any ideas wrong code?

also width of canvas element seems big though specified 100%. why?

var screenh = window.innerheight; var screenw = window.innerwidth; canvas.width = screenw; canvas.height = screenh;

move init(); bottom of code , work:

//... $('#canvas').dblclick(function () { runprefixmethod(canvas, "requestfullscreen"); }); //width/height 100% var screenh = window.innerheight; var screenw = window.innerwidth; canvas.width = screenw; canvas.height = screenh; init(); //<--here

because screenh not defined. (strange...)

demo: http://jsfiddle.net/derekl/jnf47/

bonus: debugging

first, know 1 of variables in ctx.filltext not defined, have find out 1 it:

console.log(s,flakes[flake].x, flakes[flake].y); //[some number], [some number], undefined)

so problem in flakes[flake].y. seems flakes[flake].y referring screenh, means screenh problem. variables have defined before phone call init(), moved bottom , works.

javascript firefox canvas

No comments:

Post a Comment