2

I'm having some trouble writing a JavaScript paint tool. It's a unit test and in the future will be used as a component for a larger project I'm working on. It runs in a canvas but when I try to run it, I get this error message:

Error: uncaught exception: [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIDOMCanvasRenderingContext2D.drawImage]"  nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)"  location: "JS frame :: http://rasmvillage/canvasapp/js/lib.js :: <TOP_LEVEL> :: line 52"  data: no]

I'm using the jquery library

The HTML is nothing special. Just a div#container with a canvas#imageID and canvas#boardID inside of it. Can someone help me figure out what's wrong? Thanks.

Ryan
  • 618
  • 1
  • 7
  • 16
  • A 4 year-old story about this error: http://ejohn.org/blog/why-20011-happened-so-fast/ – Ray Toal Jul 16 '11 at 03:11
  • ... and the same error on StackOverflow: http://stackoverflow.com/questions/3850312/canvas-drawimage-doesnt-draw-images-the-first-time – Ray Toal Jul 16 '11 at 03:14

1 Answers1

2

As indicated on canvas drawImage doesn't draw images the first time, make sure you don't operate on images until the images onload has fired. More advice on Image onload for static images, including a jQuery plugin that may help.

Community
  • 1
  • 1
Ray Toal
  • 86,166
  • 18
  • 182
  • 232