0

我创建了一个扩展 Container 的自定义类。但是,当我尝试向其添加侦听器时,出现以下错误:

“TypeError:this.addEventListener 不是函数

这是我的代码的最小示例:

(function() {
    var ExtendedContainerObject = function() {
        this.initialize();
    }

    // inherit from Container
    var p = ExtendedContainerObject.prototype = new createjs.Container();

    p.Container_initialize = p.initialize;
    p.initialize = function() {
        this.Container_initialize();
        console.log("this: " + this);
        this.addEventListener("custom_event", function(evt){console.log("this: " + evt.target);});

        this.button.onPress = function(evt) {
            evt.onMouseMove = function(ev) {
                dispatchEvent(new Event("custom_event", this));
            }
        }
    }

    window.ExtendedContainerObject = ExtendedContainerObject;
}());
4

1 回答 1

1

我有一个完全一样的类,它应该可以工作,你使用的是 EaselJS 0.6.0 吗?

于 2013-02-28T22:36:28.587 回答