1

我想在 Flex mobile 的 Image 组件中检测 touchBegin 事件,但是当我设置 <...touchBegin="myMethod()" /> 时,当我触摸该图像时它不会触发。

有任何想法吗?

4

2 回答 2

2

您可能看不到任何触发事件的原因是,根据设备的不同,touchBegin 可能不是在触摸开始时触发的事件,哪些设备使用 touchBegin 和哪些设备使用 mouseDown 似乎存在一些差异。

例如,为了测试这一点,我使用了将以下属性放入图像中:

touchBegin = "touchBeginHandler(event)"
mouseDown = "mouseDownHandler(event)"

以及以下代码:

protected function touchBeginHandler(event:TouchEvent):void
{
    trace("Touched");
}

protected function mouseDownHandler(event:MouseEvent):void
{
    trace("Moused");
} 

在手机模拟器和我的实际手机上,结果都是“鼠标”的跟踪语句。长话短说,尝试使用鼠标按下事件来查看是否获得了想要的结果。

于 2012-03-15T16:33:52.743 回答
1

I think you have to actually enable the multi touch gestures mode on mobile to get the touch events instead of mouse events.

http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/flash/ui/Multitouch.html#inputMode

http://sujitreddyg.wordpress.com/2010/03/17/flex-4-application-handling-touch-events-on-android-with-flash-player-10-1/

于 2012-03-15T18:17:25.650 回答