Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在Flash CC Canvas项目中删除勾选侦听器_Javascript_Flash_Canvas - Fatal编程技术网

Javascript 如何在Flash CC Canvas项目中删除勾选侦听器

Javascript 如何在Flash CC Canvas项目中删除勾选侦听器,javascript,flash,canvas,Javascript,Flash,Canvas,我试图在鼠标上方旋转一个movieclip,并在flashcc画布项目中使其停止在mouseout;我尝试了很多东西,但似乎没有一件对我有用。。。。 起初,我尝试使用setInterval,但没有成功,不知何故,我设法使用“厚”事件侦听器连续旋转它,但我无法使它在鼠标退出时停止,我正在尝试移除EventListener(“勾选”)以停止重复旋转代码。。。。我做错了什么? 顺便说一句,我是一名试图学习如何编码的平面设计师,请原谅我对代码逻辑缺乏基本的理解……还有我的英语。提前谢谢 var freq

我试图在鼠标上方旋转一个movieclip,并在flashcc画布项目中使其停止在mouseout;我尝试了很多东西,但似乎没有一件对我有用。。。。 起初,我尝试使用setInterval,但没有成功,不知何故,我设法使用“厚”事件侦听器连续旋转它,但我无法使它在鼠标退出时停止,我正在尝试移除EventListener(“勾选”)以停止重复旋转代码。。。。我做错了什么?
顺便说一句,我是一名试图学习如何编码的平面设计师,请原谅我对代码逻辑缺乏基本的理解……还有我的英语。提前谢谢

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创建了一个新函数,我认为您可以在想要调用的地方调用关闭,您可以这样做:

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