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

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

问题描述

我在Flex应用程序中有一个Canvas,其中包含的项目仅覆盖主画布的大约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.

我通常将Canvases用于复杂的多层UI,并通过css设置默认的Canvas样式,使其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天全站免登陆