2016-06-18 11 views
1

WebGLキャンバスを作成していますが、onmousemoveスニペットを使用してムービークリップボタンのロールオーバーを作成しようとしています。Adob​​e Animate CC WebGLロールオーバー状態

まず私はそうのような見えないように、ボタンのロールオーバー状態を設定します。

this.YesHOT.setVisible(false); 

は、その後、私はそれがそうのようなボタン上にあるとき、それを見えるようオンにするれる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); 
関連する問題