mouseout事件处理程序不是trrigering

时间:2014-06-19 10:28:05

标签: easeljs

我的应用中有一个奇怪的行为: 我有一组形状,每个形状都有一个mouseover和mouseout事件处理程序。 当用户移动一个形状时,它的颜色会发生变化,然后当它移出它时,它的颜色会恢复原来的颜色。

有时我不理解的事情是,鼠标输出事件根本就没有了,而且形状的颜色仍然处于悬停状态。

我尝试打印到控制台,但无法找到问题。我所知道的是它没有进入鼠标处理程序

var onMouseOver = function (e, sha, container) {
if (seat.isHovered) return;
$('body').css('cursor', 'pointer');
    var curHoveredShape = sha;
    var newShape = new createjs.Shape();
    newShape .addEventListener('mouseout', function (e) {
        onShapeMouseOut(e, e.target, e.target.parent);
    });
    newShape .graphics.beginFill(hoverdSeatColor).drawRoundRect(0, 0, 5, 5, 1.5);
    newShape .x = curHoveredSeat.x;
    newShape .y = curHoveredSeat.y;
    newShape .parent = container;
    sha.removeEventListener("mouseover", arguments.callee);
    container.removeChild(sha);
    container.addChild(newShape );
    newShape .isHovered = true;      
    lastHoveredSeat = newShape ;

    stage.update();      
}

这里是mouseout的代码:

var onMouseOut = function (e) { 
    var curShape= e.target; 
    var container = e.target.parent;

    $('body').css('cursor', 'pointer');
    var newShape = new createjs.Shape();
    newShape.graphics.beginFill(selectedSeatColor).drawRoundRect(0, 0, 5, 5, 1.5);
    newShape.x = curShape.x;
    newShape.y = curShape.y;
    newShape.parent = container;
    curShape.removeEventListener("mouseout", arguments.callee);
    container.removeChild(curShape);
    container.addChild(newShape);
    newShape.isHovered = false;
    lastHoveredSeat = null;
    newShape.addEventListener('mouseover', function(e){
        onSeatMouseOver(e, e.target, e.target.parent);
    });
    stage.update();
    $(mapManagerObj).trigger("onSeatHoveredOut");        
}

0 个答案:

没有答案