如何在 Flash CC Canvas 项目中删除滴答声侦听器

How to remove tick listener in Flash CC Canvas Project

我正在尝试在鼠标悬停时旋转 MovieCip 并使其在 Flash CC Canvas 项目中的鼠标移出时停止;我尝试了很多很多东西,none 似乎对我有用.... 最初我试图使用 setInterval 但没有成功,不知何故我设法用 "thick" 事件侦听器连续旋转它,但我不能让它在 mouseout 上停止,我正在尝试 removeEventListener ("tick") 到停止重复旋转代码....我做错了什么?
顺便说一句,我是一名试图学习如何编码的平面设计师,请原谅我对代码逻辑缺乏基本的理解……以及我的英语。提前致谢!!

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));
}
}

您需要对要删除的函数的引用。 Bind 创建了一个新函数,而且我认为你在你想调用 on 的地方调用 off,你可以这样做:

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);
    });
}