开发者

Simulate a swipe momevent in As3, Flash or Flex

Here's my dilemma:

If I add buttons to a Sprite, I have to listen for the MOUSE_DOWN or CLICK event to make the button work as it should.

However, I want the sprite that contains the button to function like开发者_如何学JAVA a touchscreen device, and I want the contents of the sprite to scroll up-and-down when you swipe it...

I am afraid the mouse events of the buttons will prevent the events from being captured by the container. This would mean that when I swipe over the button, the button get's clicked instead of the container.

I know Flex passes events down the chain of elements, but I don't believe this is the case for Flash.. ?


You should use MOUSE_UP event instead of MOUSE_DOWN, it's better practice, even if not to consider problems with scrolling. After there's nothing on MOUSE_UP you can hang

function onMouseDown(e: Event) {
  flag = true
}

on MOUSE_DOWN. After that

function onMouseDown(e: Event) {
  if (flag) {
    //scrolling here
  }
}  

and dont forget to set flag=fasle on MOUSE_UP.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜