AS3仍然将mouseEnabled一个问题,我 [英] as3 mouseEnabled still a problem for me

查看:562
本文介绍了AS3仍然将mouseEnabled一个问题,我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这几年在现在,还是有一些关于将mouseEnabled我没有收到。我有一个雪碧(例如这里的天空,它包含许多对象,其中之一是云,我不希望接收鼠标事件。我覆盖这片天空上一些其他的显示对象。我想云计算是可见的,但不能阻止鼠标事件。如果你看到透过云层一棵树,你应该可以点击树。

A couple years in now, there's still something about mouseEnabled I'm not getting. I have a Sprite (for example here "Sky", that contains many objects, one of them is a Cloud, which I do not want to receive Mouse Events. I overlay this Sky on some other display objects. I want the cloud to be visible, but not to block mouse events. If you see a tree through the clouds you should be able to click on the tree.

在天空类:

mouseEnabled = false;
cloud.mouseEnabled = false;
cloud.mouseChildren = false;

即使采用这种结构,当云是在树我不能点击树因为云块它。为什么???

Even with this configuration, when the cloud is over the tree I can't click on the tree because the cloud blocks it. Why???

推荐答案

虽然天空已经将mouseEnabled / mouseChildren设置为false ......它仍然是一个对象,它仍然占用空间,因此仍作为一个点击区域任何父容器没有将mouseEnabled / mouseChildren设置为false。

Even though Sky has mouseEnabled/mouseChildren set to false... it's still an object, it still takes up space, and therefore still acts as a hit area for any PARENT containers that don't have mouseEnabled/mouseChildren set to false.

因此​​,我怀疑你的天空对象不在同一个父容器的树对象。您的天空对象可能有它自己的父容器对象,这是罪魁祸首截取的事件

Therefore, I suspect your Sky object is not in the same parent container as your Tree object. Your Sky object probably has its own parent container object, which is the culprit intercepting the events.

要详细说明:包含任何事情都会有一个灾区,并拦截鼠标点击,即使所有的个别事物它包含(形状,子对象,等等)可能具有将mouseEnabled / mouseChildren设置为false,任何对象

To elaborate: Any object that contains ANYTHING will have a hit area and will intercept mouse clicks, even though all the individual things it contains (shapes, child objects, etc.) may have mouseEnabled/mouseChildren set to false.

所以,即使你的天空对象将mouseEnabled设置为false,你的天空(和它的孩子们)仍然占用空间,因此仍给予天空的父容器灾区拦截鼠标事件。

So even though your Sky object has mouseEnabled set to false, your Sky (and it's children) still take up space, and therefore still give Sky's parent container a hit area to intercept mouse events.

您的解决方案,因此,为确保天空的所有父容器有thier mouseEnabled属性设置为false,至少到(但不包括)树和天空对象的共同祖先容器。

Your solution, therefore, is to make sure all the parent containers of Sky have thier mouseEnabled property set to false, at least up to (but not including) the first common ancestor container of the Tree and Sky objects.

另外,通过设定将mouseEnabled =虚假和离开mouseChildren = true,则可以有一个容器,只能选择与将mouseEnabled孩子=实际接收click事件:)

Also, by setting mouseEnabled=false and leaving mouseChildren=true, you can have a container where only select children with mouseEnabled=true receive click events :)

这篇关于AS3仍然将mouseEnabled一个问题,我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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