2

I've got a movieclip that I'm using as a button. Within this movieclip is a large shadow that shows when the button is moused over. My problem is that this shadow is effecting the mouseovers and causing a much larger "catch" area for the mouseOver and mouseOut events than I want.

I've tried disabling mouse events on that child and as many combinations of mouseEnabled and mouseChildren I can think of.

Is it possible to prevent certain elements effecting the mouseover properties of it's parent, or simply defining a custom hitbox for a movieclip to use?

4

1 回答 1

3

您可以使用该hitArea属性,但实际上也可以使用mouseEnabledand进行控制mouseChildren,因此您走在了正确的轨道上:

假设您有一个名为“buttonMC”的影片剪辑,其中包含两个分别称为“clickableMC”和“shadowMC”的影片剪辑实例。

通过在 shadowMC 上将 mouseChildren 和 mouseEnabled 都设置为 false,您无法直接在该实例上监听鼠标事件。但是,点击 shadowMC 仍然会触发点击 buttonMC。为了防止在 buttonMC 上将 mouseEnabled 设置为 false。请注意,对于 buttonMC,mouseChildren 仍应为 true。

在按钮上将 mouseEnabled 设置为 false 并使其仍可单击可能听起来很奇怪,但可以将 mouseEnabled 视为确定显示对象的“图形”内容是否应可单击的标志。并且当 shadowMC 的 mouseChildren 和 mouseEnabled 设置为 false 时,就事件而言,影片剪辑的行为就像是图形(形状)。

于 2013-09-13T13:02:38.993 回答