当我获得画布并发送创建舞台时,我收到此字符串错误:
Uncaught TypeError: Cannot call method 'addEventListener' of undefined.
我的初始化函数:
function init() {
canvas = document.getElementById("testCanvas");
stage = new createjs.Stage(canvas);
screen_width = canvas.width;
screen_height = canvas.height;
contentManager = new ContentManager();
contentManager.SetDownloadCompleted(startGame);
contentManager.StartDownload();
}
给出错误的代码块是:
p.enableDOMEvents = function(enable) {
if (enable == null) { enable = true; }
var n, o, ls = this._eventListeners;
if (!enable && ls) {
for (n in ls) {
o = ls[n];
o.t.removeEventListener(n, o.f);
}
this._eventListeners = null;
} else if (enable && !ls) {
var t = window.addEventListener ? window : document;
var _this = this;
ls = this._eventListeners = {};
ls["mouseup"] = {t:t, f:function(e) { _this._handleMouseUp(e)} };
ls["mousemove"] = {t:t, f:function(e) { _this._handleMouseMove(e)} };
ls["dblclick"] = {t:t, f:function(e) { _this._handleDoubleClick(e)} };
t = this.canvas;
if (t) { ls["mousedown"] = {t:t, f:function(e) { _this._handleMouseDown(e)} }; }
for (n in ls) {
o = ls[n];
o.t.addEventListener(n, o.f);
}
}
特别是这个块:
for (n in ls) {
o = ls[n];
o.t.addEventListener(n, o.f);
}
当 'n' 的值为 时BitmapAnimation_initialize
,给出错误。我在Stage.js中找到了这段代码,该文件附带了easeljs v0.6.0的rar