2016-03-08 44 views
0

我正在嘗試在鼠標懸停上旋轉MovieCip並使其停止在Flash CC Canvas項目中的鼠標懸停上;我嘗試了許多很多東西,似乎沒有爲我工作.... 最初我試圖使用setInterval沒有成功,以某種方式我設法連續旋轉它與「厚」事件監聽器,但我不能讓它停止在mouseout上,我試圖removeEventListener(「打勾」)停止重複旋轉代碼....我做錯了什麼?順便說一句,我是一個平面設計師,試圖學習如何編碼,請原諒我對代碼邏輯....和我的英語缺乏基本的瞭解。提前致謝!!如何刪除Flash CC畫布項目中的刻度線偵聽器

var frequency = 1; 
stage.enableMouseOver(frequency); 

this.adelante.on("mouseover", rotaDerecha.bind(this)); 

function rotaDerecha() {  
    this.on("tick", Timer.bind(this)); 
    function Timer() { 
     this.rueda.rotation += 2; 
} 
    this.adelante.off("mouseout", stoper.bind(this)); 
    function stoper(){ 
     this.off("tick", Timer.bind(this)); 
} 
} 

回答

0

您需要對要刪除的功能的引用。綁定創建了一個新的功能,我也想你打電話,你想打電話onoff,你可以做這樣的事情:

var frequency = 1; 
stage.enableMouseOver(frequency); 

this.adelante.on("mouseover", rotaDerecha.bind(this)); 

function rotaDerecha() { 
    var timer = (function() { 
     this.rueda.rotation += 2; 
    }).bind(this) 
    this.on("tick", timer); 
    this.adelante.on("mouseout", function() { 
     this.off("tick", timer); 
    }.bind(this)); 
} 

或許沒有綁定,它使一個好一點可讀:

function rotaDerecha() { 
    var self = this 
    var timer = function() { 
     self.rueda.rotation += 2; 
    } 
    self.on("tick", timer); 
    self.adelante.on("mouseout", function() { 
     self.off("tick", timer); 
    }); 
}