在 Flex 中使透明面板响应 rollOver() 事件的正确方法 [英] Correct way in Flex to make a transparent panel respond to rollOver() events

查看:33
本文介绍了在 Flex 中使透明面板响应 rollOver() 事件的正确方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Flex 应用程序中有一个画布,其中的项目仅占主画布面积的 50%.

I have a Canvas in a Flex application which has items inside it that cover only about 50% of the area of the main canvas.

我希望画布响应整个区域的 rollOver 事件,而不仅仅是被里面的项目覆盖的区域.

i want the canvas to respond to rollOver events for the full area, and not just the area that is covered by the items inside.

我一直在设置以下属性来实现这一点:

I have been setting the following attributes to achieve this :

<mx:Canvas backgroundColor="white"
backgroundAlpha=".01"
rollOver="rollOver(event)">...

这会导致整个画布响应 rollOver 事件.它很好用 - 我只是不满意它,并认为必须有更好的方法来实现它.

This causes the entire canvas to respond to rollOver events. It works great - I'm just not happy with it and figure there must be a better way to achieve it.

有没有办法强制鼠标事件作用于 UIComponent 的整个区域?

Is there a way to force mouse events to act on the entire area of a UIComponent?

推荐答案

你所做的完全可以接受,虽然使用 0.01 的任意 alpha 值是不必要的,你可以将它的 backgroundAlpha 设置为一个简单的 0.

What you are doing is perfectly acceptable, although using the arbitrary alpha value of 0.01 is unnecessary, you can set it's backgroundAlpha to a simple 0.

我经常将画布用于复杂的多层 UI,并通过 css 设置我的默认画布样式,使 backgroundAlpha 为 0,backgroundColor 为 #ffffff,然后,如果我需要一个画布实际可见,我会调整它的单个 backgroundAlpha和 backgroundColor 属性.

I routinely use Canvases for complicated multi layered UI's and set up my default Canvas style via css to have a backgroundAlpha of 0 and a backgroundColor of #ffffff, then, if I need a canvas to actually be visible I adjust it's individual backgroundAlpha and backgroundColor properties.

将图形对象的 alpha 设置为 0 以使其仍然响应事件但并未完全关闭"并没有错,我们 AS 编码人员一直在这样做!

There's nothing wrong with setting a graphic object's alpha to 0 so that it still responds to events but hasn't been 'turned off' entirely, us AS coders do it all the time!

这篇关于在 Flex 中使透明面板响应 rollOver() 事件的正确方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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