Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.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
Actionscript 3 停止在Flash中冒泡的事件_Actionscript 3_Events - Fatal编程技术网

Actionscript 3 停止在Flash中冒泡的事件

Actionscript 3 停止在Flash中冒泡的事件,actionscript-3,events,Actionscript 3,Events,我有一个包含4个按钮的MovieClip: 当用户将鼠标移出容器时,它应该消失: this.resolutions.addEventListener(MouseEvent.MOUSE_OUT, this.resolutionsClose); 当用户将鼠标从4个按钮中的任何一个中移出时,事件会出现在容器中。这不是预期的行为。当4个按钮都没有鼠标移出处理程序时,如何停止传播?不要将按钮作为容器的子对象。或者在按钮上,侦听同一事件,并对其调用stopImmediatePropagation()。不

我有一个包含4个按钮的MovieClip:

当用户将鼠标移出容器时,它应该消失:

this.resolutions.addEventListener(MouseEvent.MOUSE_OUT, this.resolutionsClose);

当用户将鼠标从4个按钮中的任何一个中移出时,事件会出现在容器中。这不是预期的行为。当4个按钮都没有鼠标移出处理程序时,如何停止传播?

不要将按钮作为容器的子对象。或者在按钮上,侦听同一事件,并对其调用stopImmediatePropagation()。

不要将按钮作为容器的子对象。或者在按钮上,侦听同一事件,并对其调用stopImmediatePropagation()。

侦听容器上的MouseeEvent.ROLL\u事件。

侦听容器上的MouseeEvent.ROLL\u事件。

您有两种解决方案(加上TandemAdam建议的一种):

1-使用useCapture参数

this.resolutions.addEventListener(MouseEvent.MOUSE_OUT, this.resolutionsClose, true);
当事件在显示列表中向下钻取而不是冒泡时,您将收到该事件,因此您的容器将在其子容器之前进行调度

2-如果event.target是您的容器,请签入事件处理程序:

private function onMouseOut(e:Event):void
{
    if(e.target == this.resolutions){
    // the original dispatcher was your resolutions container.
    }
}
您有两种解决方案(加上TandemAdam建议的一种):

1-使用useCapture参数

this.resolutions.addEventListener(MouseEvent.MOUSE_OUT, this.resolutionsClose, true);
当事件在显示列表中向下钻取而不是冒泡时,您将收到该事件,因此您的容器将在其子容器之前进行调度

2-如果event.target是您的容器,请签入事件处理程序:

private function onMouseOut(e:Event):void
{
    if(e.target == this.resolutions){
    // the original dispatcher was your resolutions container.
    }
}

按钮是容器的子对象,因此当容器移动时,按钮也随之移动。你确定在4个按钮上附加鼠标监听器是最干净的方法吗?如果这是一个包含更多元素和更多嵌套的更复杂的示例,会怎么样?按钮是容器的子项,因此当容器移动时,按钮也随之移动。你确定在4个按钮上附加鼠标监听器是最干净的方法吗?如果这是一个包含更多元素和更多嵌套的更复杂的示例,该怎么办?