2016-06-18 5 views
1

WebGL 캔버스를 만들고 있는데 onmousemove 스 니펫을 사용하여 동영상 클립 롤오버를 만들려고합니다.어도비 애니메이트 CC WebGL 롤오버 상태

먼저 나는 버튼의 롤오버 상태가과 같이 눈에 보이지 않는로 설정 :

this.YesHOT.setVisible(false); 

그럼 난 그렇게 같이 버튼 위에있을 때 그것을 볼 수 있도록 설정하는 13. OnMouseMove에서는 함수를 사용

canvas.onmousemove = function(e) { 
    var boundingRect = this.Yes.getBounds(this); 
    if(isMouseOverSymbol(e.offsetX, e.offsetY, boundingRect)) {  
     this.YesHOT.setVisible(true); 
    } 
}.bind(this); 

//Function to check whether the specified point lies within the rect. 
function isMouseOverSymbol(pointX, pointY, rect) { 
    if(rect.left <= pointX && pointX <= rect.left + rect.width) 
     if(rect.top <= pointY && pointY <= rect.top + rect.height) 
      return true; 
    return false; 
} 

그래도 작동하지만 롤오버 상태는 계속 표시되며 다시 되돌아 가지 않습니다. 어떻게 다시 켜야합니까?

답변

0

실제로는 this.YesHOT.setVisible(false) 전화를 걸지 마십시오. 의도를 이해했다면 코드는 다음과 같아야합니다.

canvas.onmousemove = function(e) { 
    var boundingRect = this.Yes.getBounds(this); 
    // if mouse cursor is over the "hot" area, show effect. Otherwise hide. 
    this.YesHOT.setVisible(isMouseOverSymbol(e.offsetX, e.offsetY, boundingRect)); 
}.bind(this); 

// also hide the effect when mouse completely leaves the canvas 
canvas.onmouseleave = function() { 
    this.YesHOT.setVisible(false); 
}.bind(this);