gpt4 book ai didi

javascript - 方法 createjs.Stage 使用画架返回错误

转载 作者:行者123 更新时间:2023-11-28 09:11:48 25 4
gpt4 key购买 nike

当我获取 Canvas 并发送创建舞台时,我收到此字符串错误:

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);
}
}

尤其是这个 block :

    for (n in ls) {
o = ls[n];
o.t.addEventListener(n, o.f);
}

当'n'的值为BitmapAnimation_initialize时,给出错误。我在Stage.js中找到了这段代码,该文件附带easeljs v0.6.0的rar

最佳答案

如果您注释掉 contentManager 代码,您是否会看到此错误?看起来很奇怪。

关于javascript - 方法 createjs.Stage 使用画架返回错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16223621/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com