如何停止为子元素触发 Flex Canvas 上的 Mouse Out 事件 [英] How to stop Mouse Out event on Flex Canvas firing for child elements

查看:24
本文介绍了如何停止为子元素触发 Flex Canvas 上的 Mouse Out 事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 Canvas itemRenderer 用于我用来显示图像的容器.见下面的伪代码.

I am using a Canvas itemRenderer for a container I use to display images. See pseudo code below.

image = new Image();
image.source = data.@thumb;
this.addChild(image);
this.addEventListener(MouseEvent.MOUSE_OVER, enlarge(image));
this.addEventListener(MouseEvent.MOUSE_OUT, shrink(image)); 

当我将鼠标悬停在画布上时,会调用放大函数.但是,只要我将鼠标移到图像或其他子元素上,就会触发 MOUSE_OUT 事件.

When I mouse over the canvas, the enlarge function is called. However as soon as I move the mouse onto the image, or another child element, the MOUSE_OUT event is fired.

谁能给我指出禁用这种行为的方法?

Can anyone point me in the direction of a way to disable this behaviour?

谢谢:)

推荐答案

您应该使用 MouseEvent.ROLL_OVERMouseEvent.ROLL_OUT 事件.

You should use MouseEvent.ROLL_OVER and MouseEvent.ROLL_OUT events instead.

来自 Flash CS4 文档:

From the Flash CS4 documentation:

当鼠标从不是其子项之一的对象进入显示对象的区域或其任何子项的区域时,显示对象将调度 rollOver 事件.这与 mouseOver 事件的行为不同,每次鼠标进入显示对象容器的任何子对象的区域时都会调度该事件,即使鼠标已经在显示对象容器的另一个子对象上也是如此.

When the mouse enters the area of a display object or the area of any of its children from an object that is not one of its children, the display object dispatches the rollOver event. This is different behavior than that of the mouseOver event, which is dispatched each time the mouse enters the area of any child object of the display object container, even if the mouse was already over another child object of the display object container.

这篇关于如何停止为子元素触发 Flex Canvas 上的 Mouse Out 事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆