Javascript 创建自定义鼠标事件

Javascript 创建自定义鼠标事件,javascript,events,easeljs,Javascript,Events,Easeljs,我正在做纸牌游戏。我有一个CardSet自定义容器对象,其中包含卡片自定义容器对象。我想创建自定义事件,如:cardMouseOver和cardMouseOut,以便我可以像这样收听这些卡事件: cardSet.on('cardMouseOver', function(event) { set the event.card highlighted or anything ); cardSet.on('cardMouseOut', function(event) { set the event.c

我正在做纸牌游戏。我有一个CardSet自定义容器对象,其中包含卡片自定义容器对象。我想创建自定义事件,如:cardMouseOver和cardMouseOut,以便我可以像这样收听这些卡事件:

cardSet.on('cardMouseOver', function(event) { set the event.card highlighted or anything );
cardSet.on('cardMouseOut', function(event) { set the event.card back to normal );
在CardSet的init块中,我向每张卡添加了侦听器:

card[i].on('mouseover', function (event) {
    var evt = new createjs.Event('cardMouseOver');
    evt.card = event.target;
    this.dispatchEvent(evt);
});

问题是,当我将鼠标移到卡上时,它会触发一个接一个的重复事件。如果我移动鼠标,它会像鼠标移动一样不断触发这些事件。有什么想法吗?请问我是否还不够清楚。谢谢

启动时,仅打开鼠标悬停。在mouseover事件中,关闭mouseover并打开mouseout。在mouseout事件中,关闭mouseout并打开mouseover。运气不好,结果相同。您是否尝试附加到mouseenter和mouseleave事件?现在我刚刚尝试了,但没有成功。我认为当鼠标移动到画布上时,mouseenter被调度。