2013-07-25 43 views
0

我試圖用JS和EaselJS顯示圖像。Uncaught TypeError:Object#<HTMLImageElement> has no method'isVisible'

,我發現了錯誤Uncaught TypeError: Object #<HTMLImageElement> has no method 'isVisible'

這裏是我的代碼片段...

 function init() {        
      canvas = document.getElementById("testCanvas"); 
      start(); 
     } 

     function start() { 
      //Create new stage and point it at Canvas 
      stage = new createjs.Stage("demoCanvas"); 

      myImg = new Image(); 
      myImg.src = "./Images/SnakeHead.png"; 

任何想法,爲什麼?

謝謝!

+0

您是否將圖像添加到舞臺上? – rpg600

+0

@ Rpg600是的,我做過 – Growler

回答

0

From this page

這個錯誤通常當你添加的東西,是不是顯示對象的舞臺發生。在你的代碼中,你正在使用

Icon.prototype = new Container() 

你是否重寫了createjs命名空間?如果不是,代碼應該是

Icon.prototype = new createjs.Container(); 

如果這是問題,那麼您沒有正確地擴展容器,這將解釋錯誤。

+0

你能給我舉一個例子,說明在給定當前圖像代碼的情況下,我會如何使用它?我已經閱讀過該資源並且不理解它 – Growler

+0

http://jsfiddle.net/rafaelrinaldi/RzLQR/ – nandin

相關問題